comparison mpegaudiodec.c @ 6510:771eb7ea8b3f libavcodec

correctly set avctx->frame_size for mp3on4 and mp3adu
author bcoudurier
date Thu, 20 Mar 2008 09:36:04 +0000
parents 8e63d869a904
children b5e9dae2dbc6
comparison
equal deleted inserted replaced
6509:99294a20e11c 6510:771eb7ea8b3f
2299 skip_bits(&s->gb, 16); 2299 skip_bits(&s->gb, 16);
2300 2300
2301 dprintf(s->avctx, "frame %d:\n", s->frame_count); 2301 dprintf(s->avctx, "frame %d:\n", s->frame_count);
2302 switch(s->layer) { 2302 switch(s->layer) {
2303 case 1: 2303 case 1:
2304 avctx->frame_size = 384;
2304 nb_frames = mp_decode_layer1(s); 2305 nb_frames = mp_decode_layer1(s);
2305 break; 2306 break;
2306 case 2: 2307 case 2:
2308 avctx->frame_size = 1152;
2307 nb_frames = mp_decode_layer2(s); 2309 nb_frames = mp_decode_layer2(s);
2308 break; 2310 break;
2309 case 3: 2311 case 3:
2312 avctx->frame_size = s->lsf ? 576 : 1152;
2310 default: 2313 default:
2311 nb_frames = mp_decode_layer3(s); 2314 nb_frames = mp_decode_layer3(s);
2312 2315
2313 s->last_buf_size=0; 2316 s->last_buf_size=0;
2314 if(s->in_gb.buffer){ 2317 if(s->in_gb.buffer){
2393 } 2396 }
2394 /* update codec info */ 2397 /* update codec info */
2395 avctx->channels = s->nb_channels; 2398 avctx->channels = s->nb_channels;
2396 avctx->bit_rate = s->bit_rate; 2399 avctx->bit_rate = s->bit_rate;
2397 avctx->sub_id = s->layer; 2400 avctx->sub_id = s->layer;
2398 switch(s->layer) {
2399 case 1:
2400 avctx->frame_size = 384;
2401 break;
2402 case 2:
2403 avctx->frame_size = 1152;
2404 break;
2405 case 3:
2406 if (s->lsf)
2407 avctx->frame_size = 576;
2408 else
2409 avctx->frame_size = 1152;
2410 break;
2411 }
2412 2401
2413 if(s->frame_size<=0 || s->frame_size > buf_size){ 2402 if(s->frame_size<=0 || s->frame_size > buf_size){
2414 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); 2403 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
2415 return -1; 2404 return -1;
2416 }else if(s->frame_size < buf_size){ 2405 }else if(s->frame_size < buf_size){
2470 avctx->sample_rate = s->sample_rate; 2459 avctx->sample_rate = s->sample_rate;
2471 avctx->channels = s->nb_channels; 2460 avctx->channels = s->nb_channels;
2472 avctx->bit_rate = s->bit_rate; 2461 avctx->bit_rate = s->bit_rate;
2473 avctx->sub_id = s->layer; 2462 avctx->sub_id = s->layer;
2474 2463
2475 avctx->frame_size=s->frame_size = len; 2464 s->frame_size = len;
2476 2465
2477 if (avctx->parse_only) { 2466 if (avctx->parse_only) {
2478 out_size = buf_size; 2467 out_size = buf_size;
2479 } else { 2468 } else {
2480 out_size = mp_decode_frame(s, out_samples, buf, buf_size); 2469 out_size = mp_decode_frame(s, out_samples, buf, buf_size);
2633 } 2622 }
2634 } 2623 }
2635 2624
2636 /* update codec info */ 2625 /* update codec info */
2637 avctx->sample_rate = s->mp3decctx[0]->sample_rate; 2626 avctx->sample_rate = s->mp3decctx[0]->sample_rate;
2638 avctx->frame_size= buf_size;
2639 avctx->bit_rate = 0; 2627 avctx->bit_rate = 0;
2640 for (i = 0; i < s->frames; i++) 2628 for (i = 0; i < s->frames; i++)
2641 avctx->bit_rate += s->mp3decctx[i]->bit_rate; 2629 avctx->bit_rate += s->mp3decctx[i]->bit_rate;
2642 2630
2643 *data_size = out_size; 2631 *data_size = out_size;