]> git.sesse.net Git - nageru/commitdiff
Switch to BT.601 Y'CbCr coefficients and back to limited range.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Nov 2015 16:53:06 +0000 (17:53 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Nov 2015 16:53:06 +0000 (17:53 +0100)
Finally makes MPlayer screenshots have correct colors and luma
range all the way through.

h264encode.cpp
httpd.cpp
theme.cpp

index eb6faf3c4ec20a4c81fdde303c75b48dfc068761..4b900bfdab3f468704d4a3b2689980b19a338748 100644 (file)
@@ -343,12 +343,12 @@ static void sps_rbsp(bitstream *bs)
         bitstream_put_ui(bs, 1, 1); /* video_signal_type_present_flag */
         {
             bitstream_put_ui(bs, 5, 3);  /* video_format (5 = Unspecified) */
-            bitstream_put_ui(bs, 1, 1);  /* video_full_range_flag */
+            bitstream_put_ui(bs, 0, 1);  /* video_full_range_flag */
             bitstream_put_ui(bs, 1, 1);  /* colour_description_present_flag */
             {
                 bitstream_put_ui(bs, 1, 8);  /* colour_primaries (1 = BT.709) */
                 bitstream_put_ui(bs, 1, 8);  /* transfer_characteristics (1 = BT.709) */
-                bitstream_put_ui(bs, 1, 8);  /* matrix_coefficients (1 = BT.709) */
+                bitstream_put_ui(bs, 6, 8);  /* matrix_coefficients (6 = BT.601/SMPTE 170M) */
             }
         }
         bitstream_put_ui(bs, 0, 1); /* chroma_loc_info_present_flag */
index 3beff80e53dae05614868104f7f9ad3ad7b5ef25..57218841c73e99459e4fbe04cb73df78f4a333a4 100644 (file)
--- a/httpd.cpp
+++ b/httpd.cpp
@@ -95,8 +95,8 @@ HTTPD::Mux::Mux(AVFormatContext *avctx, int width, int height)
        // mux, this might simply get ignored. See sps_rbsp().
        avstream_video->codec->color_primaries = AVCOL_PRI_BT709;  // RGB colorspace (inout_format.color_space).
        avstream_video->codec->color_trc = AVCOL_TRC_BT709;  // Gamma curve (inout_format.gamma_curve).
-       avstream_video->codec->colorspace = AVCOL_SPC_BT709;  // YUV colorspace (output_ycbcr_format.luma_coefficients).
-       avstream_video->codec->color_range = AVCOL_RANGE_JPEG;  // Full vs. limited range (output_ycbcr_format.full_range).
+       avstream_video->codec->colorspace = AVCOL_SPC_SMPTE170M;  // YUV colorspace (output_ycbcr_format.luma_coefficients).
+       avstream_video->codec->color_range = AVCOL_RANGE_MPEG;  // Full vs. limited range (output_ycbcr_format.full_range).
        avstream_video->codec->chroma_sample_location = AVCHROMA_LOC_LEFT;  // Chroma sample location. See chroma_offset_0[] in Mixer::subsample_chroma().
        avstream_video->codec->field_order = AV_FIELD_PROGRESSIVE;
 
index 1536503adcece94f4ba20b7e2d626eb1604b86c0..2c9af01cf69b36cc150d0f98c6140cefa814b650 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -143,8 +143,14 @@ int EffectChain_finalize(lua_State* L)
                // happens in a pass not run by Movit (see Mixer::subsample_chroma()).
                output_ycbcr_format.chroma_subsampling_x = 1;
                output_ycbcr_format.chroma_subsampling_y = 1;
-               output_ycbcr_format.luma_coefficients = YCBCR_REC_709;
-               output_ycbcr_format.full_range = true;
+
+               // Rec. 709 would be the sane thing to do, but it seems many players
+               // (e.g. MPlayer and VLC) just default to BT.601 coefficients no matter
+               // what (see discussions in e.g. https://trac.ffmpeg.org/ticket/4978).
+               // We _do_ set the right flags, though, so that a player that works
+               // properly doesn't have to guess.
+               output_ycbcr_format.luma_coefficients = YCBCR_REC_601;
+               output_ycbcr_format.full_range = false;
                output_ycbcr_format.num_levels = 256;
 
                chain->add_ycbcr_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, output_ycbcr_format, YCBCR_OUTPUT_SPLIT_Y_AND_CBCR);