android Codec-specific data

android Codec-specific data

在CCodec中,CCodecBufferChannel::onWorkDone回调的时候处理csd buffer

void CCodecBufferChannel::onWorkDone(
        std::unique_ptr<C2Work> work, const sp<AMessage> &outputFormat,
        const C2StreamInitDataInfo::output *initData) {
    if (handleWork(std::move(work), outputFormat, initData)) {
        feedInputBufferIfAvailable();
    }
}

在C2Config.h中有csd的注释,csd是用来初始化codec的,在AVC/HEVC中,由SPS/PPS/VPS组成。

codec2/core/include/C2Config.h

/**
 * Codec-specific initialization data.
 *
 * This is initialization data for the codec.
 *
 * For AVC/HEVC, these are the concatenated SPS/PPS/VPS NALs.
 *
 * TODO: define for other codecs.
 */
typedef C2StreamParam<C2Info, C2BlobValue, kParamIndexInitData> C2StreamInitDataInfo;
constexpr char C2_PARAMKEY_INIT_DATA[] = "coded.init-data";

codec2play中获取csd数据

sp<AMessage> format;
(void) convertMetaDataToMessage(source->getFormat(), &format);

sp<ABuffer> csd0, csd1;
format->findBuffer("csd-0", &csd0);
format->findBuffer("csd-1", &csd1);

运行后从log中可以看到输出如下,csd里面包含了这些meta信息,log输出可以通过format->debugString().c_str()实现:

AMessage(what = 0x00000000) = {   
  string mime = "video/avc"       
  int64_t durationUs = 5240000    
  int32_t frame-count = 131       
  string language = "und"                                                        
  int32_t width = 1920                                                           
  int32_t height = 1080                                                          
  int32_t display-width = 1920                                                   
  int32_t display-height = 1080                                                  
  int32_t rotation-degrees = 0                                                   
  int32_t max-input-size = 1555201                                               
  int32_t frame-rate = 25                                                        
  int32_t profile = 8                                                            
  int32_t level = 2048                                                           
  Buffer csd-0 = {                                                               
    00000000:  00 00 00 01 67 64 00 28  ac d9 40 78 02 27 e5 84  ....gd.(..@x.'..
    00000010:  00 00 03 00 04 00 00 03  00 c8 3c 60 c6 58        ..........<`.X  
  }                                                                              
  Buffer csd-1 = {                                                               
    00000000:  00 00 00 01 68 eb e3 cb  22 c0                    ....h...".    
  }                                                                        
  string file-format = "video/mp4"                                         
}                                                                          
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值