Mercurial > libavcodec.hg
comparison mpegaudio_parser.c @ 8641:54e2916c25a5 libavcodec
Avoid allocating MPADecodeContext on stack.
Instead move relevant fields into MPADecodeHeader and use it
where appropriate.
| author | andoma |
|---|---|
| date | Fri, 23 Jan 2009 12:09:32 +0000 |
| parents | 04423b2f6e0b |
| children | 043574c5c153 |
comparison
equal
deleted
inserted
replaced
| 8640:ad979489c6e7 | 8641:54e2916c25a5 |
|---|---|
| 44 | 44 |
| 45 /* useful helper to get mpeg audio stream infos. Return -1 if error in | 45 /* useful helper to get mpeg audio stream infos. Return -1 if error in |
| 46 header, otherwise the coded frame size in bytes */ | 46 header, otherwise the coded frame size in bytes */ |
| 47 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) | 47 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) |
| 48 { | 48 { |
| 49 MPADecodeContext s1, *s = &s1; | 49 MPADecodeHeader s1, *s = &s1; |
| 50 s1.avctx = avctx; | |
| 51 | 50 |
| 52 if (ff_mpa_check_header(head) != 0) | 51 if (ff_mpa_check_header(head) != 0) |
| 53 return -1; | 52 return -1; |
| 54 | 53 |
| 55 if (ff_mpegaudio_decode_header(s, head) != 0) { | 54 if (ff_mpegaudio_decode_header(s, head) != 0) { |
| 143 s->header_count++; | 142 s->header_count++; |
| 144 s->frame_size = ret; | 143 s->frame_size = ret; |
| 145 | 144 |
| 146 #if 0 | 145 #if 0 |
| 147 /* free format: prepare to compute frame size */ | 146 /* free format: prepare to compute frame size */ |
| 148 if (ff_mpegaudio_decode_header(s, header) == 1) { | 147 if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { |
| 149 s->frame_size = -1; | 148 s->frame_size = -1; |
| 150 } | 149 } |
| 151 #endif | 150 #endif |
| 152 if(s->header_count > 1){ | 151 if(s->header_count > 1){ |
| 153 avctx->sample_rate= sr; | 152 avctx->sample_rate= sr; |
| 198 s->free_format_frame_size -= padding * 4; | 197 s->free_format_frame_size -= padding * 4; |
| 199 else | 198 else |
| 200 s->free_format_frame_size -= padding; | 199 s->free_format_frame_size -= padding; |
| 201 dprintf(avctx, "free frame size=%d padding=%d\n", | 200 dprintf(avctx, "free frame size=%d padding=%d\n", |
| 202 s->free_format_frame_size, padding); | 201 s->free_format_frame_size, padding); |
| 203 ff_mpegaudio_decode_header(s, header1); | 202 ff_mpegaudio_decode_header((MPADecodeHeader *)s, header1); |
| 204 goto next_data; | 203 goto next_data; |
| 205 } | 204 } |
| 206 p++; | 205 p++; |
| 207 } | 206 } |
| 208 /* not found: simply increase pointers */ | 207 /* not found: simply increase pointers */ |
