summaryrefslogtreecommitdiffstats
path: root/libhb/decavcodec.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-02-02 16:29:44 +0000
committerjstebbins <[email protected]>2014-02-02 16:29:44 +0000
commit2c2aae581e34e3ba891fc0374be17d29718b41ff (patch)
tree61bee2e69acd5042d49635fae6a1bafd2b510000 /libhb/decavcodec.c
parent3b6d44b8e2f3ef9d8fd221917d07b26bde741bef (diff)
libhb: fix problem with avcodec audio sample_rate
libavcodec does not yet consistently set AVFrame.sample_rate. So when it is not set, use AVCodecContext.sample_rate and log a warning. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6011 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decavcodec.c')
-rw-r--r--libhb/decavcodec.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index b4daf3cdc..7409bc8db 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -698,7 +698,16 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
if (len > 0 && got_frame)
{
info->rate_base = 1;
- info->rate = frame->sample_rate;
+ // libavcoded doesn't consistently set frame->sample_rate
+ if (frame->sample_rate != 0)
+ {
+ info->rate = frame->sample_rate;
+ }
+ else
+ {
+ info->rate = context->sample_rate;
+ hb_log("decavcodecaBSInfo: warning: invalid frame sample_rate! Using context sample_rate.");
+ }
info->samples_per_frame = frame->nb_samples;
int bps = av_get_bits_per_sample(context->codec_id);
@@ -2144,8 +2153,18 @@ static void decodeAudio(hb_audio_t *audio, hb_work_private_t *pv, uint8_t *data,
if (got_frame)
{
hb_buffer_t *out;
+ int samplerate;
+ // libavcoded doesn't yet consistently set frame->sample_rate
+ if (pv->frame->sample_rate != 0)
+ {
+ samplerate = pv->frame->sample_rate;
+ }
+ else
+ {
+ samplerate = context->sample_rate;
+ }
double duration = (90000. * pv->frame->nb_samples /
- (double)pv->frame->sample_rate);
+ (double)samplerate);
if (audio->config.out.codec & HB_ACODEC_PASS_FLAG)
{