25 #include <binder/ProcessState.h> 
   26 #include <media/stagefright/MetaData.h> 
   27 #include <media/stagefright/MediaBufferGroup.h> 
   28 #include <media/stagefright/MediaDebug.h> 
   29 #include <media/stagefright/MediaDefs.h> 
   30 #include <media/stagefright/OMXClient.h> 
   31 #include <media/stagefright/OMXCodec.h> 
   32 #include <utils/List.h> 
   42 #define OMX_QCOM_COLOR_FormatYVU420SemiPlanar 0x7FA30C00 
   44 using namespace android;
 
   78     std::map<int64_t, TimeStamp> *
ts_map;
 
   95         buf_group.add_buffer(
new MediaBuffer(
frame_size));
 
  110     virtual status_t read(MediaBuffer **
buffer,
 
  111                           const MediaSource::ReadOptions *
options) {
 
  115         if (
s->thread_exited)
 
  116             return ERROR_END_OF_STREAM;
 
  119         while (
s->in_queue->empty())
 
  122         frame = *
s->in_queue->begin();
 
  126             ret = buf_group.acquire_buffer(buffer);
 
  128                 memcpy((*buffer)->data(), frame->
buffer, frame->
size);
 
  129                 (*buffer)->set_range(0, frame->
size);
 
  130                 (*buffer)->meta_data()->clear();
 
  131                 (*buffer)->meta_data()->setInt32(kKeyIsSyncFrame,frame->
key);
 
  132                 (*buffer)->meta_data()->setInt64(kKeyTime, frame->
time);
 
  139         s->in_queue->erase(
s->in_queue->begin());
 
  165     int64_t out_frame_index = 0;
 
  178         if (frame->
status == OK) {
 
  179             sp<MetaData> outFormat = (*s->
decoder)->getFormat();
 
  180             outFormat->findInt32(kKeyWidth , &w);
 
  181             outFormat->findInt32(kKeyHeight, &h);
 
  199                 (w & 15 || h & 15)) {
 
  200                 if (((w + 15)&~15) * ((h + 15)&~15) * 3/2 == buffer->range_length()) {
 
  215             src_data[0] = (
uint8_t*)buffer->data();
 
  216             src_data[1] = src_data[0] + src_linesize[0] * h;
 
  217             src_data[2] = src_data[1] + src_linesize[1] * -(-h>>pix_desc->log2_chroma_h);
 
  219                           src_data, src_linesize,
 
  222             buffer->meta_data()->findInt64(kKeyTime, &out_frame_index);
 
  223             if (out_frame_index && s->
ts_map->count(out_frame_index) > 0) {
 
  226                 s->
ts_map->erase(out_frame_index);
 
  229             } 
else if (frame->
status == INFO_FORMAT_CHANGED) {
 
  259     sp<MetaData> meta, outFormat;
 
  287     meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
 
  288     meta->setInt32(kKeyWidth, avctx->
width);
 
  289     meta->setInt32(kKeyHeight, avctx->
height);
 
  292     android::ProcessState::self()->startThreadPool();
 
  294     s->
source    = 
new sp<MediaSource>();
 
  298     s->
ts_map    = 
new std::map<int64_t, TimeStamp>;
 
  299     s->
client    = 
new OMXClient;
 
  307     if (s->
client->connect() !=  OK) {
 
  313     s->
decoder  = 
new sp<MediaSource>();
 
  316                                   OMXCodec::kClientNeedsFramebuffer);
 
  317     if ((*s->
decoder)->start() !=  OK) {
 
  324     outFormat = (*s->
decoder)->getFormat();
 
  325     outFormat->findInt32(kKeyColorFormat, &colorFormat);
 
  327         colorFormat == OMX_COLOR_FormatYUV420SemiPlanar)
 
  329     else if (colorFormat == OMX_COLOR_FormatYCbYCr)
 
  331     else if (colorFormat == OMX_COLOR_FormatCbYCrY)
 
  362     int orig_size = avpkt->
size;
 
  371     if (avpkt && avpkt->
data) {
 
  392             if (!
frame->buffer) {
 
  400                 frame->size = orig_size;
 
  402             memcpy(
frame->buffer, ptr, orig_size);
 
  410             frame->status  = ERROR_END_OF_STREAM;
 
  447     ret_frame = 
frame->vframe;
 
  448     status  = 
frame->status;
 
  451     if (status == ERROR_END_OF_STREAM)
 
  566     "libstagefright_h264",