File Cr122-ffmpeg-new-channel-layout.patch of Package nodejs-electron

From 84d1d7adcd1697348e3f821811179c525d3b5717 Mon Sep 17 00:00:00 2001
From: Dale Curtis <dalecurtis@chromium.org>
Date: Tue, 28 Nov 2023 00:41:42 +0000
Subject: [PATCH] Roll src/third_party/ffmpeg/ c1d0dc413..866768f35 (492
 commits)

https://chromium.googlesource.com/chromium/third_party/ffmpeg.git/+log/c1d0dc4135ec..866768f35c22

$ git log c1d0dc413..866768f35 --date=short --no-merges --format='%ad %ae %s'
2023-11-22 dalecurtis README.chromium file
2023-11-22 dalecurtis Chromium patches file
2023-11-22 dalecurtis GN Configuration
2023-11-21 dalecurtis Switch to remoteexec for robosushi
2023-11-12 mypopydev vulkan_decode: fix the print format of VkDeviceSize
2023-08-28 mypopydev avdevice/decklink_dec: add explicit specifier
2023-11-20 jamrial avcodec: bump version after EVC additions
2023-09-19 d.kozinski avcodec/evc_decoder: Provided support for EVC decoder
2023-09-19 d.kozinski avcodec/evc_encoder: Provided support for EVC encoder
2023-10-17 michael avcodec/h264dec: Support skipping frames that used gray gap frames
2023-10-17 michael avcodec/h264: Avoid using gray gap frames as references
2023-10-17 michael avcodec/h264: keep track of which frames used gray references
2023-10-02 michael avcodec/h264dec: More elaborate documentation for frame_recovered
2023-10-02 michael avcodec/h264: Use FRAME_RECOVERED_HEURISTIC instead of IDR/SEI
2023-10-02 michael avcodec/h264: Seperate SEI and IDR recovery handling
2023-11-19 onemda avfilter/af_afir: remove flag that is not needed
2023-11-19 onemda avfilter/af_afir: no need to dynamically add outpad
2023-11-19 onemda avfilter/af_afir: refactor crossfade code
2023-11-19 onemda avfilter/af_afir: add timeline support
2023-11-16 remi riscv: set fast half-precision conversion
2023-11-19 onemda avfilter/af_afir: remove IR response video rendering support
2023-11-19 onemda doc/filters: add one more example for afir filter usage
2023-11-14 anton tools/general_assembly: update to conform to new rules
2023-11-14 anton tools/general_assembly: make the script executable
2023-11-18 onemda avfilter/avf_showvolume: improve step for vertical orientation
2023-11-18 onemda avfilter/avf_showvolume: draw channel names directly into output frame
2023-11-15 remi lavc/llviddsp: R-V V add_bytes
2023-11-15 remi lavc/flacdsp: R-V V LPC16 function
2023-11-15 remi lavc/flacdsp: R-V V LPC32
2023-11-15 remi checkasm/flacdsp: add LPC test
2023-11-15 remi riscv: fix builds without Zbb support
2023-11-18 mypopydev lavfi/Makefile: fix vf_cropdetect missed edge_common
2023-11-10 ffmpeg-devel apply spelling fixes
2023-11-18 onemda avfilter/af_afir: add irnorm and irlink options
2023-11-14 remi lavc/flacdsp: R-V V decorrelate_indep 16-bit packed
2023-11-14 remi lavc/flacdsp: R-V V decorrelate_indep 32-bit packed
2023-11-13 remi lavc/flacdsp: R-V V decorrelate_ms packed
2023-08-16 remi lavc/flacdsp: R-V V packed decorrelate_{l,r}s
2023-11-13 remi checkasm/flacdsp: fix ls/rs/ms tests
2023-11-08 onemda avfilter/af_adynamicequalizer: add adaptive detection mode
2023-11-06 onemda avfilter/af_adynamicequalizer: do gain calculations in log domain
2023-11-03 sunyuechi af_afir: RISC-V V fcmul_add
2023-11-12 remi lavc/llauddsp: R-V V scalarproduct_and_madd_int32
2023-11-12 remi lavc/llauddsp: R-V V scalarproduct_and_madd_int16
2023-11-12 remi checkasm: add lossless audio DSP
2023-11-15 jamrial x86/flacds: clear the high bits from pred_order in lpc_32 functions
2023-11-13 jianhui.j.dai-at-intel.com avcodec/cbs_vp8: Add support for VP8 codec bitstream
2023-11-13 jianhui.j.dai-at-intel.com avcodec/vp8: Export `vp8_token_update_probs` variable
2023-11-12 remi lavc/huffyuvdsp: basic R-V V add_hfyu_left_pred_bgr32
2023-11-12 remi checkasm/huffyuvdsp: test for add_hfyu_left_pred_bgr32
(...)
2022-08-04 andreas.rheinhardt avcodec/cbs: Use RefStruct-API for unit content
2022-08-04 andreas.rheinhardt avcodec/refstruct: Allow checking for exclusive ownership
2022-08-04 andreas.rheinhardt avcodec/dovi_rpu: Use RefStruct API for Vdr data
2022-08-04 andreas.rheinhardt avcodec/wavpack: Use RefStruct API for DSD context
2023-07-17 andreas.rheinhardt avcodec/vp8: Use RefStruct API for seg_map
2022-08-04 andreas.rheinhardt avcodec/hevc_ps: Use RefStruct API for parameter sets
2022-08-04 andreas.rheinhardt avcodec/h264_ps: Use RefStruct API for SPS/PPS
2022-08-04 andreas.rheinhardt avcodec/get_buffer: Use RefStruct API for FramePool
2022-08-04 andreas.rheinhardt avcodec/refstruct: Add simple API for refcounted objects
2023-10-03 remi lavu/fixed_dsp: R-V V scalarproduct
2023-10-07 onemda avformat/wavdec: w64: do not error out for broken files if data start is found
2023-10-06 onemda avcodec/mlpenc: rename some variables related to thd
2023-10-03 andreas.rheinhardt avcodec/mpegvideo: Move allocating new_picture to the encoder
2023-07-17 jamrial fftools/ffplay: stop injecting stream side data in packets
2023-07-17 jamrial fftools/ffmpeg: stop injecting stream side data in packets
2023-07-17 jamrial avcodec/decode: propagate global side data to frames
2023-07-17 jamrial avcodec/hevcdec: check for DOVI configuration record in AVCodecContext side data
2023-07-16 jamrial fftools/ffprobe: stop using AVStream.side_data
2023-07-16 jamrial fftools/ffplay: stop using AVStream.side_data
2023-07-16 jamrial fftools/ffmpeg: stop using AVStream.side_data
2023-09-26 jamrial avcodec/packet: add some documentation for AVPacketSideData
2023-07-16 jamrial avformat/avformat: use the side data from AVStream.codecpar
2023-07-16 jamrial avcodec/codec_par: add side data to AVCodecParameters
2023-07-16 jamrial avcodec/packet: add generic side data helpers
2023-10-06 andreas.rheinhardt avfilter/vulkan_filter: Remove unused label
2023-10-06 onemda avcodec/mlpdec: set extended_substream_info from header
2023-08-26 stefasab doc/encoders/libopus: clarify lowdelay and cutoff options
2023-08-26 stefasab doc/encoders/libxvid: fix references for me_quality option
2023-08-26 stefasab doc/encoders/libx264: clarify meaning of level option
2023-08-26 stefasab lavc: clarify meaning of avctx.level option
2023-10-03 leo.izen avcodec/jpegxl_parser: fix various memory issues
2023-10-03 leo.izen avcodec/jpegxl_parser: add some icc profile checks
2023-09-01 stefasab ffprobe: introduce section type, use for the compact output
2023-09-01 stefasab ffprobe: correct section name for side data piece
2023-08-31 stefasab ffprobe: factorize side data printing to dedicated function
2023-10-03 onemda avcodec/mlpenc: restructure code and resolve several bugs
2023-10-05 dev hwcontext_vulkan: properly support STORAGE usage for mutliplane images
2023-09-30 ben vulkan_hevc: handle non-contiguous SPS/PPS/VPS ids
2023-10-03 ffmpeg-devel avcodec/svt-av1: Set force_key_frames only when gop_size == 1
2023-10-03 andreas.rheinhardt avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags
2023-10-03 andreas.rheinhardt avcodec/rv10: Replace switch by LUT
2023-10-03 andreas.rheinhardt avcodec/rv10: Remove dead code
2023-10-02 andreas.rheinhardt avcodec/h263dec, mpeg4videodec: Parse extradata during init
2023-10-01 andreas.rheinhardt avcodec/mpegvideo_dec: Always initialize IDCTDSPContext during init
2023-10-01 andreas.rheinhardt avcodec/mpegvideo_dec: Don't zero context on init failure
2023-10-01 andreas.rheinhardt avcodec/mpeg12dec: Don't initialize IDCT more than once
2023-10-02 remi lavc/ac3: add R-V Zbb extract_exponents
2023-10-04 jamrial avcodec/hcadec: add a flush callback
2023-10-01 remi swscale/rgb2rgb: R-V V deinterleaveBytes
2023-10-01 remi swscale/rgb2rgb: fix extra iteration in R-V V interleave

Created with:
  roll-dep src/third_party/ffmpeg

R=jrummell

Bug: 1504603
Change-Id: Ia40313bc2abcb0594543019bc8d1c22fbf7bde82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5055586
Reviewed-by: John Rummell <jrummell@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1229653}
---
 DEPS                                          |   2 +-
 media/ffmpeg/ffmpeg_common.cc                 | 169 +++++++++---------
 .../filters/audio_video_metadata_extractor.cc |  17 +-
 media/filters/ffmpeg_demuxer_unittest.cc      |   4 +-
 third_party/ffmpeg                            |   2 +-
 5 files changed, 97 insertions(+), 97 deletions(-)

diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index 3c97e4a6cf4c7..a55e4ab51d5b3 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -653,15 +653,6 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
       profile = ProfileIDToVideoCodecProfile(codec_context->profile);
   }
 
-  void* display_matrix =
-      av_stream_get_side_data(stream, AV_PKT_DATA_DISPLAYMATRIX, nullptr);
-
-  VideoTransformation video_transformation = VideoTransformation();
-  if (display_matrix) {
-    video_transformation = VideoTransformation::FromFFmpegDisplayMatrix(
-        static_cast<int32_t*>(display_matrix));
-  }
-
   if (!color_space.IsSpecified()) {
     // VP9 frames may have color information, but that information cannot
     // express new color spaces, like HDR. For that reason, color space
@@ -718,91 +709,92 @@
                       codec_context->extradata + codec_context->extradata_size);
   }
 
-  if (stream->nb_side_data) {
-    for (int i = 0; i < stream->nb_side_data; ++i) {
-      AVPacketSideData side_data = stream->side_data[i];
-      switch (side_data.type) {
-        case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: {
-          AVMasteringDisplayMetadata* mdcv =
-              reinterpret_cast<AVMasteringDisplayMetadata*>(side_data.data);
-          gfx::HdrMetadataSmpteSt2086 smpte_st_2086;
-          if (mdcv->has_primaries) {
-            smpte_st_2086.primaries = {
-                static_cast<float>(av_q2d(mdcv->display_primaries[0][0])),
-                static_cast<float>(av_q2d(mdcv->display_primaries[0][1])),
-                static_cast<float>(av_q2d(mdcv->display_primaries[1][0])),
-                static_cast<float>(av_q2d(mdcv->display_primaries[1][1])),
-                static_cast<float>(av_q2d(mdcv->display_primaries[2][0])),
-                static_cast<float>(av_q2d(mdcv->display_primaries[2][1])),
-                static_cast<float>(av_q2d(mdcv->white_point[0])),
-                static_cast<float>(av_q2d(mdcv->white_point[1])),
-            };
-          }
-          if (mdcv->has_luminance) {
-            smpte_st_2086.luminance_max = av_q2d(mdcv->max_luminance);
-            smpte_st_2086.luminance_min = av_q2d(mdcv->min_luminance);
-          }
-
-          // TODO(https://crbug.com/1446302): Consider rejecting metadata that
-          // does not specify all values.
-          if (mdcv->has_primaries || mdcv->has_luminance) {
-            hdr_metadata.smpte_st_2086 = smpte_st_2086;
-          }
-          break;
+  VideoTransformation video_transformation = VideoTransformation();
+  for (int i = 0; i < stream->codecpar->nb_coded_side_data; ++i) {
+    const auto& side_data = stream->codecpar->coded_side_data[i];
+    switch (side_data.type) {
+      case AV_PKT_DATA_DISPLAYMATRIX: {
+        CHECK_EQ(side_data.size, sizeof(int32_t) * 3 * 3);
+        video_transformation = VideoTransformation::FromFFmpegDisplayMatrix(
+            reinterpret_cast<int32_t*>(side_data.data));
+        break;
+      }
+      case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: {
+        AVMasteringDisplayMetadata* mdcv =
+            reinterpret_cast<AVMasteringDisplayMetadata*>(side_data.data);
+        gfx::HdrMetadataSmpteSt2086 smpte_st_2086;
+        if (mdcv->has_primaries) {
+          smpte_st_2086.primaries = {
+              static_cast<float>(av_q2d(mdcv->display_primaries[0][0])),
+              static_cast<float>(av_q2d(mdcv->display_primaries[0][1])),
+              static_cast<float>(av_q2d(mdcv->display_primaries[1][0])),
+              static_cast<float>(av_q2d(mdcv->display_primaries[1][1])),
+              static_cast<float>(av_q2d(mdcv->display_primaries[2][0])),
+              static_cast<float>(av_q2d(mdcv->display_primaries[2][1])),
+              static_cast<float>(av_q2d(mdcv->white_point[0])),
+              static_cast<float>(av_q2d(mdcv->white_point[1])),
+          };
         }
-        case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: {
-          AVContentLightMetadata* clli =
-              reinterpret_cast<AVContentLightMetadata*>(side_data.data);
-          hdr_metadata.cta_861_3 =
-              gfx::HdrMetadataCta861_3(clli->MaxCLL, clli->MaxFALL);
-          break;
+        if (mdcv->has_luminance) {
+          smpte_st_2086.luminance_max = av_q2d(mdcv->max_luminance);
+          smpte_st_2086.luminance_min = av_q2d(mdcv->min_luminance);
+        }
+
+        // TODO(https://crbug.com/1446302): Consider rejecting metadata that
+        // does not specify all values.
+        if (mdcv->has_primaries || mdcv->has_luminance) {
+          hdr_metadata.smpte_st_2086 = smpte_st_2086;
         }
+        break;
+      }
+      case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: {
+        AVContentLightMetadata* clli =
+            reinterpret_cast<AVContentLightMetadata*>(side_data.data);
+        hdr_metadata.cta_861_3 =
+            gfx::HdrMetadataCta861_3(clli->MaxCLL, clli->MaxFALL);
+        break;
+      }
 #if BUILDFLAG(ENABLE_PLATFORM_DOLBY_VISION)
-        case AV_PKT_DATA_DOVI_CONF: {
-          AVDOVIDecoderConfigurationRecord* dovi =
-              reinterpret_cast<AVDOVIDecoderConfigurationRecord*>(
-                  side_data.data);
-          VideoType type;
-          type.codec = VideoCodec::kDolbyVision;
-          type.level = dovi->dv_level;
-          type.color_space = color_space;
-          type.hdr_metadata_type = gfx::HdrMetadataType::kNone;
-          switch (dovi->dv_profile) {
-            case 0:
-              type.profile = VideoCodecProfile::DOLBYVISION_PROFILE0;
-              break;
-            case 4:
-              type.profile = VideoCodecProfile::DOLBYVISION_PROFILE4;
-              break;
-            case 5:
-              type.profile = VideoCodecProfile::DOLBYVISION_PROFILE5;
-              break;
-            case 7:
-              type.profile = VideoCodecProfile::DOLBYVISION_PROFILE7;
-              break;
-            case 8:
-              type.profile = VideoCodecProfile::DOLBYVISION_PROFILE8;
-              break;
-            case 9:
-              type.profile = VideoCodecProfile::DOLBYVISION_PROFILE9;
-              break;
-            default:
-              type.profile = VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN;
-              break;
-          }
-          // Treat dolby vision contents as dolby vision codec only if the
-          // device support clear DV decoding, otherwise use the original
-          // HEVC or AVC codec and profile.
-          if (media::IsSupportedVideoType(type)) {
-            codec = type.codec;
-            profile = type.profile;
-          }
-          break;
+      case AV_PKT_DATA_DOVI_CONF: {
+        AVDOVIDecoderConfigurationRecord* dovi =
+            reinterpret_cast<AVDOVIDecoderConfigurationRecord*>(side_data.data);
+        VideoType type;
+        type.codec = VideoCodec::kDolbyVision;
+        type.level = dovi->dv_level;
+        type.color_space = color_space;
+        type.hdr_metadata_type = gfx::HdrMetadataType::kNone;
+        switch (dovi->dv_profile) {
+          case 0:
+            type.profile = VideoCodecProfile::DOLBYVISION_PROFILE0;
+            break;
+          case 5:
+            type.profile = VideoCodecProfile::DOLBYVISION_PROFILE5;
+            break;
+          case 7:
+            type.profile = VideoCodecProfile::DOLBYVISION_PROFILE7;
+            break;
+          case 8:
+            type.profile = VideoCodecProfile::DOLBYVISION_PROFILE8;
+            break;
+          case 9:
+            type.profile = VideoCodecProfile::DOLBYVISION_PROFILE9;
+            break;
+          default:
+            type.profile = VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN;
+            break;
         }
+        // Treat dolby vision contents as dolby vision codec only if the
+        // device support clear DV decoding, otherwise use the original
+        // HEVC or AVC codec and profile.
+        if (media::IsSupportedVideoType(type)) {
+          codec = type.codec;
+          profile = type.profile;
+        }
+        break;
+      }
 #endif  // BUILDFLAG(ENABLE_PLATFORM_DOLBY_VISION)
       default:
         break;
-      }
     }
   }
 
diff --git a/media/filters/audio_video_metadata_extractor.cc b/media/filters/audio_video_metadata_extractor.cc
index cb002490a6322..e841b4ad13383 100644
--- a/media/filters/audio_video_metadata_extractor.cc
+++ b/media/filters/audio_video_metadata_extractor.cc
@@ -113,13 +113,16 @@ bool AudioVideoMetadataExtractor::Extract(DataSource* source,
     if (!stream)
       continue;
 
-    void* display_matrix =
-        av_stream_get_side_data(stream, AV_PKT_DATA_DISPLAYMATRIX, nullptr);
-    if (display_matrix) {
-      rotation_ = VideoTransformation::FromFFmpegDisplayMatrix(
-                      static_cast<int32_t*>(display_matrix))
-                      .rotation;
-      info.tags["rotate"] = base::NumberToString(rotation_);
+    for (int j = 0; j < stream->codecpar->nb_coded_side_data; j++) {
+      const AVPacketSideData& sd = stream->codecpar->coded_side_data[j];
+      if (sd.type == AV_PKT_DATA_DISPLAYMATRIX) {
+        CHECK_EQ(sd.size, sizeof(int32_t) * 3 * 3);
+        rotation_ = VideoTransformation::FromFFmpegDisplayMatrix(
+                        reinterpret_cast<int32_t*>(sd.data))
+                        .rotation;
+        info.tags["rotate"] = base::NumberToString(rotation_);
+        break;
+      }
     }
 
     // Extract dictionary from streams also. Needed for containers that attach
openSUSE Build Service is sponsored by