[FFmpeg-cvslog] dvbsubdec: add version checking

JULIAN GARDNER git at videolan.org
Fri Oct 14 20:29:02 CEST 2011


ffmpeg | branch: master | JULIAN GARDNER <joolzg at btinternet.com> | Fri Oct 14 16:41:21 2011 +0200| [0f8d77199aeb76a0c65d6506d3104cba3514fd2a] | committer: Michael Niedermayer

dvbsubdec: add version checking

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f8d77199aeb76a0c65d6506d3104cba3514fd2a
---

 libavcodec/dvbsubdec.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 25552be..c348aed 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -154,6 +154,7 @@ static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
 
 typedef struct DVBSubCLUT {
     int id;
+    int version;
 
     uint32_t clut4[4];
     uint32_t clut16[16];
@@ -180,6 +181,7 @@ typedef struct DVBSubObjectDisplay {
 
 typedef struct DVBSubObject {
     int id;
+    int version;
 
     int type;
 
@@ -199,6 +201,7 @@ typedef struct DVBSubRegionDisplay {
 
 typedef struct DVBSubRegion {
     int id;
+    int version;
 
     int width;
     int height;
@@ -229,6 +232,7 @@ typedef struct DVBSubContext {
     int composition_id;
     int ancillary_id;
 
+    int version;
     int time_out;
     DVBSubRegion *region_list;
     DVBSubCLUT   *clut_list;
@@ -375,6 +379,8 @@ static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
         ctx->ancillary_id   = AV_RB16(avctx->extradata + 2);
     }
 
+    ctx->version = -1;
+
     default_clut.id = -1;
     default_clut.next = NULL;
 
@@ -928,6 +934,7 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx,
 
     const uint8_t *buf_end = buf + buf_size;
     int i, clut_id;
+    int version;
     DVBSubCLUT *clut;
     int entry_id, depth , full_range;
     int y, cr, cb, alpha;
@@ -945,6 +952,7 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx,
         av_dlog(avctx, "\n");
 
     clut_id = *buf++;
+    version = ((*buf)>>4)&15;
     buf += 1;
 
     clut = get_clut(ctx, clut_id);
@@ -955,11 +963,16 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx,
         memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
 
         clut->id = clut_id;
+        clut->version = -1;
 
         clut->next = ctx->clut_list;
         ctx->clut_list = clut;
     }
 
+    if (clut->version != version) {
+
+    clut->version = version;
+
     while (buf + 4 < buf_end) {
         entry_id = *buf++;
 
@@ -1001,6 +1014,7 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx,
         if (depth & 0x20)
             clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
     }
+    }
 }
 
 
@@ -1011,6 +1025,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
 
     const uint8_t *buf_end = buf + buf_size;
     int region_id, object_id;
+    int version;
     DVBSubRegion *region;
     DVBSubObject *object;
     DVBSubObjectDisplay *display;
@@ -1027,11 +1042,13 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
         region = av_mallocz(sizeof(DVBSubRegion));
 
         region->id = region_id;
+        region->version = -1;
 
         region->next = ctx->region_list;
         ctx->region_list = region;
     }
 
+    version = ((*buf)>>4) & 15;
     fill = ((*buf++) >> 3) & 1;
 
     region->width = AV_RB16(buf);
@@ -1127,13 +1144,21 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
     const uint8_t *buf_end = buf + buf_size;
     int region_id;
     int page_state;
+    int timeout;
+    int version;
 
     if (buf_size < 1)
         return;
 
-    ctx->time_out = *buf++;
+    timeout = *buf++;
+    version = ((*buf)>>4) & 15;
     page_state = ((*buf++) >> 2) & 3;
 
+    if (ctx->version != version) {
+
+    ctx->time_out = timeout;
+    ctx->version = version;
+
     av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
 
     if (page_state == 1 || page_state == 2) {
@@ -1184,6 +1209,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
 
         av_free(display);
     }
+    }
 
 }
 



More information about the ffmpeg-cvslog mailing list