avcodec/dvbsubdec: Cosmetics

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
pull/344/head^2
Limin Wang 4 years ago
parent c32114e0a5
commit 9cfed6d84a
  1. 94
      libavcodec/dvbsubdec.c

@ -710,8 +710,8 @@ static void compute_default_clut(DVBSubContext *ctx, uint8_t *clut, AVSubtitleRe
}
count = FFMAX(i - 1, 1);
for (i--; i>=0; i--) {
int v = i*255/count;
for (i--; i >= 0; i--) {
int v = i * 255 / count;
AV_WN32(clut + 4*list_inv[i], RGBA(v/2,v,v/2,v));
}
}
@ -737,7 +737,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou
}
/* Not touching AVSubtitles again*/
if(sub->num_rects) {
if (sub->num_rects) {
avpriv_request_sample(ctx, "Different Version of Segment asked Twice");
return AVERROR_PATCHWELCOME;
}
@ -747,7 +747,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou
sub->num_rects++;
}
if(ctx->compute_edt == 0) {
if (ctx->compute_edt == 0) {
sub->end_display_time = ctx->time_out * 1000;
*got_output = 1;
} else if (ctx->prev_start != AV_NOPTS_VALUE) {
@ -851,7 +851,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
fail:
if (sub->rects) {
for(i=0; i<sub->num_rects; i++) {
for (i=0; i < sub->num_rects; i++) {
rect = sub->rects[i];
if (rect) {
av_freep(&rect->data[0]);
@ -1088,53 +1088,53 @@ static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
if (clut->version != version) {
clut->version = version;
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
}
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
}
full_range = (*buf++) & 1;
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
buf += 2;
}
if (y == 0)
alpha = 0xff;
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
ff_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
ff_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80 && entry_id < 4)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40 && entry_id < 16)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
if (depth & 0x80 && entry_id < 4)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40 && entry_id < 16)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
@ -1210,7 +1210,7 @@ static int dvbsub_parse_region_segment(AVCodecContext *avctx,
}
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
if (region->depth < 2 || region->depth > 8) {
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
}
@ -1318,7 +1318,7 @@ static int dvbsub_parse_page_segment(AVCodecContext *avctx,
ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if(ctx->compute_edt == 1)
if (ctx->compute_edt == 1)
save_subtitle_set(avctx, sub, got_output);
if (page_state == 1 || page_state == 2) {
@ -1601,7 +1601,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
{
DVBSubContext *ctx = avctx->priv_data;
if(ctx->compute_edt == 0)
if (ctx->compute_edt == 0)
save_subtitle_set(avctx, sub, got_output);
#ifdef DEBUG
save_display_set(ctx);
@ -1717,12 +1717,12 @@ static int dvbsub_decode(AVCodecContext *avctx,
}
end:
if(ret < 0) {
if (ret < 0) {
*got_sub_ptr = 0;
avsubtitle_free(sub);
return ret;
} else {
if(ctx->compute_edt == 1 )
if (ctx->compute_edt == 1)
FFSWAP(int64_t, ctx->prev_start, sub->pts);
}

Loading…
Cancel
Save