]> granicus.if.org Git - handbrake/commitdiff
libhb: fix decavcodecaBSInfo again...
authorjstebbins <jstebbins.hb@gmail.com>
Sat, 22 Feb 2014 01:34:50 +0000 (01:34 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sat, 22 Feb 2014 01:34:50 +0000 (01:34 +0000)
... forgot to check for error return from avcodec_decode_audio4

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6055 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/decavcodec.c

index 4a0b925a7e5213711653d52cd1604b22d0e9630f..4b9d992d93aa7a1cf6f8d5692f6fc50ad0dc1835 100644 (file)
@@ -649,26 +649,27 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
     {
         return -1;
     }
-    unsigned char *pbuffer;
-    int pos, pbuffer_size;
+    unsigned char *parse_buffer;
+    int parse_pos, dec_pos, parse_buffer_size;
 
     while (buf != NULL && !ret)
     {
-        pos = 0;
-        while (pos < buf->size)
+        parse_pos = 0;
+        while (parse_pos < buf->size)
         {
-            int len, truehd_mono = 0;
+            int parse_len, truehd_mono = 0;
 
             if (parser != NULL)
             {
-                len = av_parser_parse2(parser, context, &pbuffer, &pbuffer_size,
-                                       buf->data + pos, buf->size - pos,
-                                       buf->s.start, buf->s.start, 0);
+                parse_len = av_parser_parse2(parser, context,
+                                &parse_buffer, &parse_buffer_size,
+                                buf->data + parse_pos, buf->size - parse_pos,
+                                buf->s.start, buf->s.start, 0);
             }
             else
             {
-                pbuffer = buf->data + pos;
-                len = pbuffer_size = buf->size - pos;
+                parse_buffer = buf->data + parse_pos;
+                parse_len = parse_buffer_size = buf->size - parse_pos;
             }
 
             // libavcodec can't decode TrueHD Mono (bug #356)
@@ -684,17 +685,23 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
                 context->request_channel_layout = 0;
             }
 
-            if (pbuffer_size > 0)
+            dec_pos = 0;
+            while (dec_pos < parse_buffer_size)
             {
+                int dec_len;
                 int got_frame;
                 AVFrame *frame = av_frame_alloc();
                 AVPacket avp;
                 av_init_packet(&avp);
-                avp.data = pbuffer;
-                avp.size = pbuffer_size;
+                avp.data = parse_buffer + dec_pos;
+                avp.size = parse_buffer_size - dec_pos;
 
-                len = avcodec_decode_audio4(context, frame, &got_frame, &avp);
-                if (len > 0 && got_frame)
+                dec_len = avcodec_decode_audio4(context, frame, &got_frame, &avp);
+                if (dec_len < 0)
+                {
+                    break;
+                }
+                if (dec_len > 0 && got_frame)
                 {
                     info->rate_base          = 1;
                     // libavcoded doesn't consistently set frame->sample_rate
@@ -768,8 +775,9 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
                     ret = 1;
                     break;
                 }
+                dec_pos += dec_len;
             }
-            pos += len;
+            parse_pos += parse_len;
         }
         buf = buf->next;
     }