changeset 10320:44f31c1c9acc libavcodec

Make sure that dv encoder initializes all encoded packet data. The specification does not say which value to use for unused parts, so fill all unused bytes with 0xff, which is consistent with what DV usually uses for reserved or unused parts.
author reimar
date Tue, 29 Sep 2009 19:17:18 +0000
parents 9e43db5ad7ef
children 7f609ddb85bf
files dv.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dv.c	Tue Sep 29 18:03:30 2009 +0000
+++ b/dv.c	Tue Sep 29 19:17:18 2009 +0000
@@ -1102,8 +1102,17 @@
             av_log(NULL, AV_LOG_ERROR, "ac bitstream overflow\n");
     }
 
-    for (j=0; j<5*s->sys->bpm; j++)
+    for (j=0; j<5*s->sys->bpm; j++) {
+       int pos;
+       int size = pbs[j].size_in_bits >> 3;
        flush_put_bits(&pbs[j]);
+       pos = put_bits_count(&pbs[j]) >> 3;
+       if (pos > size) {
+           av_log(avctx, AV_LOG_ERROR, "bitstream written beyond buffer size\n");
+           return -1;
+       }
+       memset(pbs[j].buf + pos, 0xff, size - pos);
+    }
 
     return 0;
 }