Browse Source

lavc/ccaption_dec: simplify by incrementing cursor_column inside write_char()

tags/n3.0
Aman Gupta Clément Bœsch 9 years ago
parent
commit
086093c77c
1 changed files with 6 additions and 15 deletions
  1. +6
    -15
      libavcodec/ccaption_dec.c

+ 6
- 15
libavcodec/ccaption_dec.c View File

@@ -175,6 +175,7 @@ static int write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch)


if (col < SCREEN_COLUMNS) { if (col < SCREEN_COLUMNS) {
row[col] = ch; row[col] = ch;
if (ch) ctx->cursor_column++;
return 0; return 0;
} }
/* We have extra space at end only for null character */ /* We have extra space at end only for null character */
@@ -320,7 +321,6 @@ static int reap_screen(CCaptionSubContext *ctx, int64_t pts)
static void handle_textattr(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) static void handle_textattr(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
{ {
int i = lo - 0x20; int i = lo - 0x20;
int ret;
struct Screen *screen = get_writing_screen(ctx); struct Screen *screen = get_writing_screen(ctx);


if (i >= 32) if (i >= 32)
@@ -330,9 +330,7 @@ static void handle_textattr(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
ctx->cursor_font = pac2_attribs[i][1]; ctx->cursor_font = pac2_attribs[i][1];


SET_FLAG(screen->row_used, ctx->cursor_row); SET_FLAG(screen->row_used, ctx->cursor_row);
ret = write_char(ctx, screen, ' ');
if (ret == 0)
ctx->cursor_column++;
write_char(ctx, screen, ' ');
} }


static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
@@ -342,7 +340,7 @@ static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
}; };
const int index = ( (hi<<1) & 0x0e) | ( (lo>>5) & 0x01 ); const int index = ( (hi<<1) & 0x0e) | ( (lo>>5) & 0x01 );
struct Screen *screen = get_writing_screen(ctx); struct Screen *screen = get_writing_screen(ctx);
int indent, i, ret;
int indent, i;


if (row_map[index] <= 0) { if (row_map[index] <= 0) {
av_log(ctx, AV_LOG_DEBUG, "Invalid pac index encountered\n"); av_log(ctx, AV_LOG_DEBUG, "Invalid pac index encountered\n");
@@ -357,9 +355,7 @@ static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
ctx->cursor_column = 0; ctx->cursor_column = 0;
indent = pac2_attribs[lo][2]; indent = pac2_attribs[lo][2];
for (i = 0; i < indent; i++) { for (i = 0; i < indent; i++) {
ret = write_char(ctx, screen, ' ');
if (ret == 0)
ctx->cursor_column++;
write_char(ctx, screen, ' ');
} }
} }


@@ -390,18 +386,13 @@ static void handle_delete_end_of_row(CCaptionSubContext *ctx, char hi, char lo)
static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts) static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts)
{ {
struct Screen *screen = get_writing_screen(ctx); struct Screen *screen = get_writing_screen(ctx);
int ret;


SET_FLAG(screen->row_used, ctx->cursor_row); SET_FLAG(screen->row_used, ctx->cursor_row);


ret = write_char(ctx, screen, hi);
if (ret == 0)
ctx->cursor_column++;
write_char(ctx, screen, hi);


if (lo) { if (lo) {
ret = write_char(ctx, screen, lo);
if (ret == 0)
ctx->cursor_column++;
write_char(ctx, screen, lo);
} }
write_char(ctx, screen, 0); write_char(ctx, screen, 0);




Loading…
Cancel
Save