#include <stdint.h>#include "avcodec.h"#include "parser.h"Go to the source code of this file.
Data Structures | |
| struct | AACAC3ParseContext |
Functions | |
| int | ff_aac_ac3_parse (AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) |
| int ff_aac_ac3_parse | ( | AVCodecParserContext * | s1, | |
| AVCodecContext * | avctx, | |||
| const uint8_t ** | poutbuf, | |||
| int * | poutbuf_size, | |||
| const uint8_t * | buf, | |||
| int | buf_size | |||
| ) |
Definition at line 26 of file aac_ac3_parser.c.
References AACAC3ParseContext::bit_rate, AVCodecContext::bit_rate, AVCodecContext::channels, AACAC3ParseContext::channels, AVCodecContext::codec_id, CODEC_ID_AC3, END_NOT_FOUND, ff_combine_frame(), FFMIN, AVCodecContext::frame_size, AACAC3ParseContext::header_size, len, AACAC3ParseContext::need_next_header, NULL, AACAC3ParseContext::pc, AACAC3ParseContext::remaining_size, AVCodecContext::request_channels, s1, AACAC3ParseContext::sample_rate, AVCodecContext::sample_rate, AACAC3ParseContext::samples, AACAC3ParseContext::state, and AACAC3ParseContext::sync.
00030 { 00031 AACAC3ParseContext *s = s1->priv_data; 00032 ParseContext *pc = &s->pc; 00033 int len, i; 00034 int new_frame_start; 00035 00036 get_next: 00037 i=END_NOT_FOUND; 00038 if(s->remaining_size <= buf_size){ 00039 if(s->remaining_size && !s->need_next_header){ 00040 i= s->remaining_size; 00041 s->remaining_size = 0; 00042 }else{ //we need a header first 00043 len=0; 00044 for(i=s->remaining_size; i<buf_size; i++){ 00045 s->state = (s->state<<8) + buf[i]; 00046 if((len=s->sync(s->state, s, &s->need_next_header, &new_frame_start))) 00047 break; 00048 } 00049 if(len<=0){ 00050 i=END_NOT_FOUND; 00051 }else{ 00052 i-= s->header_size -1; 00053 s->remaining_size = len; 00054 if(!new_frame_start){ 00055 s->remaining_size += i; 00056 goto get_next; 00057 } 00058 } 00059 } 00060 } 00061 00062 if(ff_combine_frame(pc, i, &buf, &buf_size)<0){ 00063 s->remaining_size -= FFMIN(s->remaining_size, buf_size); 00064 *poutbuf = NULL; 00065 *poutbuf_size = 0; 00066 return buf_size; 00067 } 00068 00069 *poutbuf = buf; 00070 *poutbuf_size = buf_size; 00071 00072 /* update codec info */ 00073 avctx->sample_rate = s->sample_rate; 00074 /* allow downmixing to stereo (or mono for AC3) */ 00075 if(avctx->request_channels > 0 && 00076 avctx->request_channels < s->channels && 00077 (avctx->request_channels <= 2 || 00078 (avctx->request_channels == 1 && 00079 avctx->codec_id == CODEC_ID_AC3))) { 00080 avctx->channels = avctx->request_channels; 00081 } else { 00082 avctx->channels = s->channels; 00083 } 00084 avctx->bit_rate = s->bit_rate; 00085 avctx->frame_size = s->samples; 00086 00087 return i; 00088 }
1.5.1