1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00
FFmpeg/libavcodec/av1dec.h
Andreas Rheinhardt 02220b88fc avcodec/thread: Don't use ThreadFrame when unnecessary
The majority of frame-threaded decoders (mainly the intra-only)
need exactly one part of ThreadFrame: The AVFrame. They don't
need the owners nor the progress, yet they had to use it because
ff_thread_(get|release)_buffer() requires it.

This commit changes this and makes these functions work with ordinary
AVFrames; the decoders that need the extra fields for progress
use ff_thread_(get|release)_ext_buffer() which work exactly
as ff_thread_(get|release)_buffer() used to do.

This also avoids some unnecessary allocations of progress AVBuffers,
namely for H.264 and HEVC film grain frames: These frames are not
used for synchronization and therefore don't need a ThreadFrame.

Also move the ThreadFrame structure as well as ff_thread_ref_frame()
to threadframe.h, the header for frame-threaded decoders with
inter-frame dependencies.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:22:35 +01:00

90 lines
2.2 KiB
C

/*
* AV1 video decoder
* *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_AV1DEC_H
#define AVCODEC_AV1DEC_H
#include <stdint.h>
#include "libavutil/buffer.h"
#include "libavutil/frame.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "cbs.h"
#include "cbs_av1.h"
typedef struct AV1Frame {
AVFrame *f;
AVBufferRef *hwaccel_priv_buf;
void *hwaccel_picture_private;
AVBufferRef *header_ref;
AV1RawFrameHeader *raw_frame_header;
int temporal_id;
int spatial_id;
uint8_t gm_invalid[AV1_NUM_REF_FRAMES];
uint8_t gm_type[AV1_NUM_REF_FRAMES];
int32_t gm_params[AV1_NUM_REF_FRAMES][6];
uint8_t skip_mode_frame_idx[2];
AV1RawFilmGrainParams film_grain;
uint8_t coded_lossless;
} AV1Frame;
typedef struct TileGroupInfo {
uint32_t tile_offset;
uint32_t tile_size;
uint16_t tile_row;
uint16_t tile_column;
} TileGroupInfo;
typedef struct AV1DecContext {
const AVClass *class;
AVCodecContext *avctx;
enum AVPixelFormat pix_fmt;
CodedBitstreamContext *cbc;
CodedBitstreamFragment current_obu;
AVBufferRef *seq_ref;
AV1RawSequenceHeader *raw_seq;
AVBufferRef *header_ref;
AV1RawFrameHeader *raw_frame_header;
TileGroupInfo *tile_group_info;
uint16_t tile_num;
uint16_t tg_start;
uint16_t tg_end;
int operating_point_idc;
AV1Frame ref[AV1_NUM_REF_FRAMES];
AV1Frame cur_frame;
// AVOptions
int operating_point;
} AV1DecContext;
#endif /* AVCODEC_AV1DEC_H */