annotate imx_dump_header_bsf.c @ 7785:a969253a82ff libavcodec

fix issue 616 on roundup : decoding of short flac files
author jai_menon
date Wed, 03 Sep 2008 13:31:33 +0000
parents fa59236be6af
children 04423b2f6e0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5038
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
1 /*
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
2 * imx dump header bitstream filter
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
3 * Copyright (c) 2007 Baptiste Coudurier.
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
4 *
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
5 * This file is part of FFmpeg.
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
6 *
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
11 *
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
15 * Lesser General Public License for more details.
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
16 *
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
20 */
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
21
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
22 /**
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
23 * @file imx_dump_header_bsf.c
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
24 * imx dump header bitstream filter
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
25 * modifies bitstream to fit in mov and be decoded by final cut pro decoder
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
26 */
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
27
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
28 #include "avcodec.h"
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
29 #include "bytestream.h"
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
30
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
31
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
32 static int imx_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
33 uint8_t **poutbuf, int *poutbuf_size,
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
34 const uint8_t *buf, int buf_size, int keyframe)
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
35 {
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
36 /* MXF essence element key */
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
37 static const uint8_t imx_header[16] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x05,0x01,0x01,0x00 };
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
38 uint8_t *poutbufp;
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
39
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
40 if (avctx->codec_id != CODEC_ID_MPEG2VIDEO) {
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
41 av_log(avctx, AV_LOG_ERROR, "imx bitstream filter only applies to mpeg2video codec\n");
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
42 return 0;
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
43 }
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
44
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
45 *poutbuf = av_malloc(buf_size + 20 + FF_INPUT_BUFFER_PADDING_SIZE);
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
46 poutbufp = *poutbuf;
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
47 bytestream_put_buffer(&poutbufp, imx_header, 16);
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
48 bytestream_put_byte(&poutbufp, 0x83); /* KLV BER long form */
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
49 bytestream_put_be24(&poutbufp, buf_size);
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
50 bytestream_put_buffer(&poutbufp, buf, buf_size);
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
51 *poutbuf_size = poutbufp - *poutbuf;
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
52 return 1;
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
53 }
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
54
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
55 AVBitStreamFilter imx_dump_header_bsf = {
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
56 "imxdump",
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
57 0,
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
58 imx_dump_header,
fa59236be6af move imx_dump_header bitstream filter in its own file
aurel
parents:
diff changeset
59 };