Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 4104:04ff8026d9c0 libavcodec
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
author | michael |
---|---|
date | Mon, 30 Oct 2006 02:19:55 +0000 |
parents | 4da24acf4e20 |
children | af24e0fd0d1b |
comparison
equal
deleted
inserted
replaced
4103:4da24acf4e20 | 4104:04ff8026d9c0 |
---|---|
1188 return 0; | 1188 return 0; |
1189 } | 1189 } |
1190 | 1190 |
1191 /* useful helper to get mpeg audio stream infos. Return -1 if error in | 1191 /* useful helper to get mpeg audio stream infos. Return -1 if error in |
1192 header, otherwise the coded frame size in bytes */ | 1192 header, otherwise the coded frame size in bytes */ |
1193 int mpa_decode_header(AVCodecContext *avctx, uint32_t head) | 1193 int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate) |
1194 { | 1194 { |
1195 MPADecodeContext s1, *s = &s1; | 1195 MPADecodeContext s1, *s = &s1; |
1196 | 1196 |
1197 if (ff_mpa_check_header(head) != 0) | 1197 if (ff_mpa_check_header(head) != 0) |
1198 return -1; | 1198 return -1; |
1215 else | 1215 else |
1216 avctx->frame_size = 1152; | 1216 avctx->frame_size = 1152; |
1217 break; | 1217 break; |
1218 } | 1218 } |
1219 | 1219 |
1220 avctx->sample_rate = s->sample_rate; | 1220 *sample_rate = s->sample_rate; |
1221 avctx->channels = s->nb_channels; | 1221 avctx->channels = s->nb_channels; |
1222 avctx->bit_rate = s->bit_rate; | 1222 avctx->bit_rate = s->bit_rate; |
1223 avctx->sub_id = s->layer; | 1223 avctx->sub_id = s->layer; |
1224 return s->frame_size; | 1224 return s->frame_size; |
1225 } | 1225 } |
2545 /* free format: prepare to compute frame size */ | 2545 /* free format: prepare to compute frame size */ |
2546 s->frame_size = -1; | 2546 s->frame_size = -1; |
2547 return -1; | 2547 return -1; |
2548 } | 2548 } |
2549 /* update codec info */ | 2549 /* update codec info */ |
2550 avctx->sample_rate = s->sample_rate; | |
2551 avctx->channels = s->nb_channels; | 2550 avctx->channels = s->nb_channels; |
2552 avctx->bit_rate = s->bit_rate; | 2551 avctx->bit_rate = s->bit_rate; |
2553 avctx->sub_id = s->layer; | 2552 avctx->sub_id = s->layer; |
2554 switch(s->layer) { | 2553 switch(s->layer) { |
2555 case 1: | 2554 case 1: |
2572 }else if(s->frame_size < buf_size){ | 2571 }else if(s->frame_size < buf_size){ |
2573 av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n"); | 2572 av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n"); |
2574 } | 2573 } |
2575 | 2574 |
2576 out_size = mp_decode_frame(s, out_samples, buf, buf_size); | 2575 out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
2577 if(out_size>=0) | 2576 if(out_size>=0){ |
2578 *data_size = out_size; | 2577 *data_size = out_size; |
2579 else | 2578 avctx->sample_rate = s->sample_rate; |
2579 //FIXME maybe move the other codec info stuff from above here too | |
2580 }else | |
2580 av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed | 2581 av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed |
2581 s->frame_size = 0; | 2582 s->frame_size = 0; |
2582 return buf_size; | 2583 return buf_size; |
2583 } | 2584 } |
2584 | 2585 |