Libav
|
00001 /* 00002 * imx dump header bitstream filter 00003 * Copyright (c) 2007 Baptiste Coudurier 00004 * 00005 * This file is part of FFmpeg. 00006 * 00007 * FFmpeg is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * FFmpeg is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with FFmpeg; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00028 #include "avcodec.h" 00029 #include "bytestream.h" 00030 00031 00032 static int imx_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, 00033 uint8_t **poutbuf, int *poutbuf_size, 00034 const uint8_t *buf, int buf_size, int keyframe) 00035 { 00036 /* MXF essence element key */ 00037 static const uint8_t imx_header[16] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x05,0x01,0x01,0x00 }; 00038 uint8_t *poutbufp; 00039 00040 if (avctx->codec_id != CODEC_ID_MPEG2VIDEO) { 00041 av_log(avctx, AV_LOG_ERROR, "imx bitstream filter only applies to mpeg2video codec\n"); 00042 return 0; 00043 } 00044 00045 *poutbuf = av_malloc(buf_size + 20 + FF_INPUT_BUFFER_PADDING_SIZE); 00046 poutbufp = *poutbuf; 00047 bytestream_put_buffer(&poutbufp, imx_header, 16); 00048 bytestream_put_byte(&poutbufp, 0x83); /* KLV BER long form */ 00049 bytestream_put_be24(&poutbufp, buf_size); 00050 bytestream_put_buffer(&poutbufp, buf, buf_size); 00051 *poutbuf_size = poutbufp - *poutbuf; 00052 return 1; 00053 } 00054 00055 AVBitStreamFilter imx_dump_header_bsf = { 00056 "imxdump", 00057 0, 00058 imx_dump_header, 00059 };