On Sunday 17 April 2016 08:41:32 pm Jan Ekstrom wrote: > Yes, the YCbCr values in palettes are matched accordingly against the > video stream. As per the specification: > "Y, Cr and Cb shall have the same color matrix as the associated HDMV > Video stream: 525-60/625-50 (Rec.601); 1080i, 720p (ITU-709)"
Does attached make it better? Carl Eugen
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 07a2a78..29fc09a 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -96,6 +96,7 @@ typedef struct PGSSubContext { PGSSubPalettes palettes; PGSSubObjects objects; int forced_subs_only; + int hdtv; } PGSSubContext; static void flush_cache(AVCodecContext *avctx) @@ -136,6 +137,9 @@ static PGSSubPalette * find_palette(int id, PGSSubPalettes *palettes) static av_cold int init_decoder(AVCodecContext *avctx) { + PGSSubContext *ctx = avctx->priv_data; + ctx->hdtv = -1; + avctx->pix_fmt = AV_PIX_FMT_PAL8; return 0; @@ -354,8 +358,13 @@ static int parse_palette_segment(AVCodecContext *avctx, cb = bytestream_get_byte(&buf); alpha = bytestream_get_byte(&buf); - YUV_TO_RGB1(cb, cr); - YUV_TO_RGB2(r, g, b, y); + if (ctx->hdtv > 0) { + YUV_TO_RGB1_CCIR(cb, cr); + YUV_TO_RGB2_CCIR(r, g, b, y); + } else { + YUV_TO_RGB1(cb, cr); + YUV_TO_RGB2(r, g, b, y); + } ff_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha); @@ -387,6 +396,11 @@ static int parse_presentation_segment(AVCodecContext *avctx, // Video descriptor int w = bytestream_get_be16(&buf); int h = bytestream_get_be16(&buf); + if (h > 625 && ctx->hdtv == -1) { + ctx->hdtv = 1; + } else { + ctx->hdtv = 0; + } ctx->presentation.pts = pts;
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel