FFmpeg: libavcodec/libaomdec.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (c) 2010, Google, Inc.
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * AV1 decoder support via libaom
24 */
25
26 #include <aom/aom_decoder.h>
27 #include <aom/aomdx.h>
28
32
37
41
43 const struct aom_codec_iface *iface)
44 {
46 struct aom_codec_dec_cfg deccfg = {
48 };
49
52
53 if (aom_codec_dec_init(&
ctx->decoder, iface, &deccfg, 0) != AOM_CODEC_OK) {
54 const char *
error = aom_codec_error(&
ctx->decoder);
58 }
59
60 return 0;
61 }
62
64 {
67
68 for (
i = 0;
i <
desc->nb_components;
i++) {
71 int x, y;
72
74 w = (
w +
img->x_chroma_shift) >>
img->x_chroma_shift;
75 h = (
h +
img->y_chroma_shift) >>
img->y_chroma_shift;
76 }
77
78 for (y = 0; y <
h; y++) {
79 uint16_t *
src = (uint16_t *)(
img->planes[
i] + y *
img->stride[
i]);
81 for (x = 0; x <
w; x++)
83 }
84 }
85 }
86
87 // returns 0 on success, AVERROR_INVALIDDATA otherwise
89 {
92 };
97
99 case AOM_IMG_FMT_I420:
100 case AOM_IMG_FMT_I42016:
101 if (
img->bit_depth == 8) {
105 return 0;
106 }
else if (
img->bit_depth == 10) {
110 return 0;
111 }
else if (
img->bit_depth == 12) {
115 return 0;
116 } else {
118 }
119 case AOM_IMG_FMT_I422:
120 case AOM_IMG_FMT_I42216:
121 if (
img->bit_depth == 8) {
124 return 0;
125 }
else if (
img->bit_depth == 10) {
128 return 0;
129 }
else if (
img->bit_depth == 12) {
132 return 0;
133 } else {
135 }
136 case AOM_IMG_FMT_I444:
137 case AOM_IMG_FMT_I44416:
138 if (
img->bit_depth == 8) {
141 return 0;
142 }
else if (
img->bit_depth == 10) {
145 return 0;
146 }
else if (
img->bit_depth == 12) {
149 return 0;
150 } else {
152 }
153
154 default:
156 }
157 }
158
161 {
163 const void *iter =
NULL;
164 struct aom_image *
img;
166
168 AOM_CODEC_OK) {
169 const char *
error = aom_codec_error(&
ctx->decoder);
170 const char *detail = aom_codec_error_detail(&
ctx->decoder);
171
173 if (detail)
175 detail);
177 }
178
179 if ((
img = aom_codec_get_frame(&
ctx->decoder, &iter))) {
184 }
185
188 img->fmt,
img->bit_depth);
190 }
191
198 }
201
202 #ifdef AOM_CTRL_AOMD_GET_FRAME_FLAGS
203 {
204 aom_codec_frame_flags_t
flags;
205 ret = aom_codec_control(&
ctx->decoder, AOMD_GET_FRAME_FLAGS, &
flags);
206 if (
ret == AOM_CODEC_OK) {
208 if (
flags & (AOM_FRAME_IS_KEY | AOM_FRAME_IS_INTRAONLY))
210 else if (
flags & AOM_FRAME_IS_SWITCH)
212 else
214 }
215 }
216 #endif
217
222 INT_MAX);
224
225 if ((
img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) &&
img->bit_depth == 8)
227 else {
228 const uint8_t *
planes[4] = {
img->planes[0],
img->planes[1],
img->planes[2] };
229 const int stride[4] = {
img->stride[0],
img->stride[1],
img->stride[2] };
230
233 }
234 *got_frame = 1;
235 }
237 }
238
240 {
242 aom_codec_destroy(&
ctx->decoder);
243 return 0;
244 }
245
247 {
248 return aom_init(avctx, aom_codec_av1_dx());
249 }
250
252 .
p.
name =
"libaom-av1",
263 .p.wrapper_name = "libaom",
264 };
static void error(const char *err)
static av_cold int aom_free(AVCodecContext *avctx)
static av_cold int aom_init(AVCodecContext *avctx, const struct aom_codec_iface *iface)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVColorSpace colorspace
YUV colorspace type.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
@ AVCOL_RANGE_JPEG
Full range content.
static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
#define AV_PIX_FMT_YUV420P10
#define AV_LOG_VERBOSE
Detailed information.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec p
The public AVCodec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int key_frame
1 -> keyframe, 0-> not
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_PIX_FMT_YUV444P10
struct aom_codec_ctx decoder
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_CODEC_DECODE_CB(func)
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
const AVProfile ff_av1_profiles[]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_PIX_FMT_GRAY10
enum AVColorRange color_range
MPEG vs JPEG YUV range.
const FFCodec ff_libaom_av1_decoder
@ AV_PICTURE_TYPE_I
Intra.
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PICTURE_TYPE_SP
Switching Predicted.
static const struct @328 planes[]
enum AVPictureType pict_type
Picture type of the frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define FF_PROFILE_AV1_MAIN
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int av1_init(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV444P12
static int aom_decode(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_INFO
Standard information.
#define i(width, name, range_min, range_max)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
#define FF_PROFILE_AV1_PROFESSIONAL
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
#define AV_PIX_FMT_YUV420P12
static void image_copy_16_to_8(AVFrame *pic, struct aom_image *img)
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
main external API structure.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
This structure stores compressed data.
int width
picture width / height.
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_PROFILE_AV1_HIGH
#define AV_PIX_FMT_GRAY12
AVColorRange
Visual content value range.
Generated on Wed Aug 24 2022 21:41:30 for FFmpeg by
doxygen
1.8.17