1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60

media / base / video_frame_converter_internals.h [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_VIDEO_FRAME_CONVERTER_INTERNALS_H_
#define MEDIA_BASE_VIDEO_FRAME_CONVERTER_INTERNALS_H_

#include "media/base/video_frame.h"
#include "third_party/libyuv/include/libyuv.h"

namespace media::internals {

// These are all VideoFrame based versions of equivalent libyuv calls. They
// allow calling code to not have to manually coordinate which planes, strides,
// and sizes go with which method and parameter (which is not always obvious).
//
// If a libyuv method returns a status code, the method has a bool signature and
// will return false if conversion failed.
//
// If the source and destination format have alpha it will be converted.
//
// If a method doesn't support scaling it's noted in the comments.

bool ARGBScale(const VideoFrame& src_frame,
               VideoFrame& dst_frame,
               libyuv::FilterMode filter);

bool ARGBToI420x(const VideoFrame& src_frame, VideoFrame& dst_frame);

bool ARGBToI444x(const VideoFrame& src_frame, VideoFrame& dst_frame);

bool ARGBToNV12x(const VideoFrame& src_frame, VideoFrame& dst_frame);

bool ABGRToARGB(const VideoFrame& src_frame, VideoFrame& dst_frame);

// Also converts between I420, I422, I444 and vice versa.
void I4xxxScale(const VideoFrame& src_frame, VideoFrame& dst_frame);

// Scaling not supported.
bool I420xToNV12x(const VideoFrame& src_frame, VideoFrame& dst_frame);

// Scaling not supported.
bool I444xToNV12x(const VideoFrame& src_frame, VideoFrame& dst_frame);

// Scaling not supported.
void MergeUV(const VideoFrame& src_frame, VideoFrame& dst_frame);

// Scaling not supported.
void SplitUV(const VideoFrame& src_frame, VideoFrame& dst_frame);

bool NV12xScale(const VideoFrame& src_frame,
                VideoFrame& dst_frame,
                libyuv::FilterMode filter);

// Scaling not supported.
bool NV12xToI420x(const VideoFrame& src_frame, VideoFrame& dst_frame);

}  // namespace media::internals

#endif  // MEDIA_BASE_VIDEO_FRAME_CONVERTER_INTERNALS_H_