[FFmpeg-cvslog] lavc/ccaption_dec: reap_screen() is responsible for clearing output buffer and signaling screen_changed

Aman Gupta git at videolan.org
Fri Jan 8 20:26:51 CET 2016


ffmpeg | branch: master | Aman Gupta <aman at tmm1.net> | Tue Jan  5 14:53:29 2016 -0800| [53ee84f811c3a3e55c688116d41310e76d285d9e] | committer: Clément Bœsch

lavc/ccaption_dec: reap_screen() is responsible for clearing output buffer and signaling screen_changed

moves the screen_changed bit and the bprint_clear into reap_screen() so
the logic is centralized and callers do not need to touch the bit or the
buffer before calling reap_screen()

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

 libavcodec/ccaption_dec.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index cd431cc..bfdf511 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -282,6 +282,7 @@ static int reap_screen(CCaptionSubContext *ctx, int64_t pts)
     int ret = 0;
     struct Screen *screen = ctx->screen + ctx->active_screen;
     ctx->start_time = ctx->startv_time;
+    av_bprint_clear(&ctx->buffer);
 
     for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
     {
@@ -298,12 +299,14 @@ static int reap_screen(CCaptionSubContext *ctx, int64_t pts)
                 break;
             }
         }
-
     }
+
     if (screen->row_used && ctx->buffer.len >= 2) {
         ctx->buffer.len -= 2;
         ctx->buffer.str[ctx->buffer.len] = 0;
+        ctx->screen_changed = 1;
     }
+
     ctx->startv_time = pts;
     ctx->end_time = pts;
     return ret;
@@ -367,7 +370,6 @@ static void handle_edm(CCaptionSubContext *ctx, int64_t pts)
 
     reap_screen(ctx, pts);
     screen->row_used = 0;
-    ctx->screen_changed = 1;
 }
 
 static void handle_eoc(CCaptionSubContext *ctx, int64_t pts)
@@ -460,7 +462,6 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint
             ff_dlog(ctx, "carriage return\n");
             reap_screen(ctx, pts);
             roll_up(ctx);
-            ctx->screen_changed = 1;
             ctx->cursor_column = 0;
             break;
         case 0x2f:
@@ -514,7 +515,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
             continue;
         else
             process_cc608(ctx, avpkt->pts, *(bptr + i + 1) & 0x7f, *(bptr + i + 2) & 0x7f);
-        if (ctx->screen_changed && *ctx->buffer.str)
+        if (ctx->screen_changed)
         {
             int start_time = av_rescale_q(ctx->start_time, avctx->time_base, (AVRational){ 1, 100 });
             int end_time = av_rescale_q(ctx->end_time, avctx->time_base, (AVRational){ 1, 100 });
@@ -524,7 +525,6 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
                 return ret;
             sub->pts = av_rescale_q(ctx->start_time, avctx->time_base, AV_TIME_BASE_Q);
             ctx->screen_changed = 0;
-            av_bprint_clear(&ctx->buffer);
         }
     }
 



More information about the ffmpeg-cvslog mailing list