Mercurial > libavcodec.hg
annotate bitstream_filter.c @ 5033:3c034e71667f libavcodec
move mp3_header_decompress bitstream filter in its own file
| author | aurel |
|---|---|
| date | Sat, 19 May 2007 00:24:34 +0000 |
| parents | d47ee2d1d7da |
| children | b955154b7ca9 |
| rev | line source |
|---|---|
|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
1 /* |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
3 * |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
4 * This file is part of FFmpeg. |
|
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
5 * |
|
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
10 * |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
14 * Lesser General Public License for more details. |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
15 * |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3422
diff
changeset
|
19 */ |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
20 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
21 #include "avcodec.h" |
| 4166 | 22 #include "mpegaudio.h" |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
23 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
24 AVBitStreamFilter *first_bitstream_filter= NULL; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
25 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
26 void av_register_bitstream_filter(AVBitStreamFilter *bsf){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
27 bsf->next = first_bitstream_filter; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
28 first_bitstream_filter= bsf; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
29 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
30 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
31 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
32 AVBitStreamFilter *bsf= first_bitstream_filter; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
33 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
34 while(bsf){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
35 if(!strcmp(name, bsf->name)){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
36 AVBitStreamFilterContext *bsfc= av_mallocz(sizeof(AVBitStreamFilterContext)); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
37 bsfc->filter= bsf; |
| 3422 | 38 bsfc->priv_data= av_mallocz(bsf->priv_data_size); |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
39 return bsfc; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
40 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
41 bsf= bsf->next; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
42 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
43 return NULL; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
44 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
45 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
46 void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc){ |
| 3422 | 47 av_freep(&bsfc->priv_data); |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
48 av_parser_close(bsfc->parser); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
49 av_free(bsfc); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
50 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
51 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
52 int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
53 AVCodecContext *avctx, const char *args, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
54 uint8_t **poutbuf, int *poutbuf_size, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
55 const uint8_t *buf, int buf_size, int keyframe){ |
| 3422 | 56 *poutbuf= (uint8_t *) buf; |
| 57 *poutbuf_size= buf_size; | |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
58 return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
59 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
60 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
61 static int dump_extradata(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
62 uint8_t **poutbuf, int *poutbuf_size, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
63 const uint8_t *buf, int buf_size, int keyframe){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
64 int cmd= args ? *args : 0; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
65 /* cast to avoid warning about discarding qualifiers */ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
66 if(avctx->extradata){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
67 if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) && cmd=='a') |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
68 ||(keyframe && (cmd=='k' || !cmd)) |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
69 ||(cmd=='e') |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
70 /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
71 int size= buf_size + avctx->extradata_size; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
72 *poutbuf_size= size; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
73 *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
74 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
75 memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
76 memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
77 return 1; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
78 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
79 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
80 return 0; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
81 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
82 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
83 static int remove_extradata(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
84 uint8_t **poutbuf, int *poutbuf_size, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
85 const uint8_t *buf, int buf_size, int keyframe){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
86 int cmd= args ? *args : 0; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
87 AVCodecParserContext *s; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
88 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
89 if(!bsfc->parser){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
90 bsfc->parser= av_parser_init(avctx->codec_id); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
91 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
92 s= bsfc->parser; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
93 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
94 if(s && s->parser->split){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
95 if( (((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) && cmd=='a') |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
96 ||(!keyframe && cmd=='k') |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
97 ||(cmd=='e' || !cmd) |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
98 ){ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
99 int i= s->parser->split(avctx, buf, buf_size); |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
100 buf += i; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
101 buf_size -= i; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
102 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
103 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
104 *poutbuf= (uint8_t *) buf; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
105 *poutbuf_size= buf_size; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
106 |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
107 return 0; |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
108 } |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
109 |
| 3422 | 110 static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
| 111 uint8_t **poutbuf, int *poutbuf_size, | |
| 112 const uint8_t *buf, int buf_size, int keyframe){ | |
| 113 int amount= args ? atoi(args) : 10000; | |
| 114 unsigned int *state= bsfc->priv_data; | |
| 115 int i; | |
| 116 | |
| 117 *poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |
| 118 | |
| 119 memcpy(*poutbuf, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |
| 120 for(i=0; i<buf_size; i++){ | |
| 121 (*state) += (*poutbuf)[i] + 1; | |
| 122 if(*state % amount == 0) | |
| 123 (*poutbuf)[i] = *state; | |
| 124 } | |
| 125 return 1; | |
| 126 } | |
| 127 | |
| 4166 | 128 static int mp3_header_compress(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
| 129 uint8_t **poutbuf, int *poutbuf_size, | |
| 130 const uint8_t *buf, int buf_size, int keyframe){ | |
|
4167
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
131 uint32_t header, extraheader; |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
132 int mode_extension, header_size; |
| 4166 | 133 |
| 134 if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){ | |
| 135 av_log(avctx, AV_LOG_ERROR, "not standards compliant\n"); | |
| 136 return -1; | |
| 137 } | |
| 138 | |
| 4364 | 139 header = AV_RB32(buf); |
| 4166 | 140 mode_extension= (header>>4)&3; |
| 141 | |
|
4167
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
142 if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){ |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
143 output_unchanged: |
| 4166 | 144 *poutbuf= (uint8_t *) buf; |
| 145 *poutbuf_size= buf_size; | |
| 146 | |
| 147 av_log(avctx, AV_LOG_INFO, "cannot compress %08X\n", header); | |
| 148 return 0; | |
| 149 } | |
| 150 | |
|
4167
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
151 if(avctx->extradata_size == 0){ |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
152 avctx->extradata_size=15; |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
153 avctx->extradata= av_malloc(avctx->extradata_size); |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
154 strcpy(avctx->extradata, "FFCMP3 0.0"); |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
155 memcpy(avctx->extradata+11, buf, 4); |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
156 } |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
157 if(avctx->extradata_size != 15){ |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
158 av_log(avctx, AV_LOG_ERROR, "Extradata invalid\n"); |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
159 return -1; |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
160 } |
| 4364 | 161 extraheader = AV_RB32(avctx->extradata+11); |
|
4167
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
162 if((extraheader&MP3_MASK) != (header&MP3_MASK)) |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
163 goto output_unchanged; |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
164 |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
165 header_size= (header&0x10000) ? 4 : 6; |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
166 |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
167 *poutbuf_size= buf_size - header_size; |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
168 *poutbuf= av_malloc(buf_size - header_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
a3134db4857e
store a identifer and the first header in extradata
michael
parents:
4166
diff
changeset
|
169 memcpy(*poutbuf, buf + header_size, buf_size - header_size + FF_INPUT_BUFFER_PADDING_SIZE); |
| 4166 | 170 |
| 171 if(avctx->channels==2){ | |
| 172 if((header & (3<<19)) != 3<<19){ | |
| 173 (*poutbuf)[1] &= 0x3F; | |
| 174 (*poutbuf)[1] |= mode_extension<<6; | |
| 175 FFSWAP(int, (*poutbuf)[1], (*poutbuf)[2]); | |
| 176 }else{ | |
| 177 (*poutbuf)[1] &= 0x8F; | |
| 178 (*poutbuf)[1] |= mode_extension<<4; | |
| 179 } | |
| 180 } | |
| 181 | |
| 182 return 1; | |
| 183 } | |
| 184 | |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
185 #ifdef CONFIG_DUMP_EXTRADATA_BSF |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
186 AVBitStreamFilter dump_extradata_bsf={ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
187 "dump_extra", |
| 3422 | 188 0, |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
189 dump_extradata, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
190 }; |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
191 #endif |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
192 |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
193 #ifdef CONFIG_REMOVE_EXTRADATA_BSF |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
194 AVBitStreamFilter remove_extradata_bsf={ |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
195 "remove_extra", |
| 3422 | 196 0, |
|
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
197 remove_extradata, |
|
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff
changeset
|
198 }; |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
199 #endif |
| 3422 | 200 |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
201 #ifdef CONFIG_NOISE_BSF |
| 3422 | 202 AVBitStreamFilter noise_bsf={ |
| 203 "noise", | |
| 204 sizeof(int), | |
| 205 noise, | |
| 206 }; | |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
207 #endif |
| 4166 | 208 |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
209 #ifdef CONFIG_MP3_HEADER_COMPRESS_BSF |
| 4166 | 210 AVBitStreamFilter mp3_header_compress_bsf={ |
| 211 "mp3comp", | |
| 212 0, | |
| 213 mp3_header_compress, | |
| 214 }; | |
|
4994
3fa689636240
allow to enable or disable every bitstream filters individually
aurel
parents:
4364
diff
changeset
|
215 #endif |
