2020-09-09 05:39:55 +02:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2024-02-21 00:09:12 +02:00
|
|
|
#include "libavutil/buffer.h"
|
2023-03-06 01:32:23 +02:00
|
|
|
#include "libavutil/fifo.h"
|
2022-02-06 15:49:23 +02:00
|
|
|
#include "libavutil/frame.h"
|
2020-09-09 05:39:55 +02:00
|
|
|
#include "libavutil/pixfmt.h"
|
|
|
|
#include "avcodec.h"
|
2023-05-20 00:54:49 +02:00
|
|
|
#include "packet.h"
|
2020-09-09 05:39:55 +02:00
|
|
|
#include "cbs.h"
|
|
|
|
#include "cbs_av1.h"
|
2024-02-23 22:24:32 +02:00
|
|
|
#include "dovi_rpu.h"
|
2024-04-19 16:07:07 +02:00
|
|
|
#include "progressframe.h"
|
2020-09-09 05:39:55 +02:00
|
|
|
|
|
|
|
typedef struct AV1Frame {
|
2024-04-19 16:07:07 +02:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct AVFrame *f;
|
|
|
|
};
|
|
|
|
ProgressFrame pf;
|
|
|
|
};
|
2020-09-09 05:39:55 +02:00
|
|
|
|
2022-08-04 16:21:03 +02:00
|
|
|
void *hwaccel_picture_private; ///< RefStruct reference
|
2020-09-09 05:39:55 +02:00
|
|
|
|
2022-08-04 11:59:16 +02:00
|
|
|
AV1RawOBU *header_ref; ///< RefStruct reference backing raw_frame_header.
|
2020-11-12 21:59:37 +02:00
|
|
|
AV1RawFrameHeader *raw_frame_header;
|
|
|
|
|
2020-10-16 18:34:31 +02:00
|
|
|
int temporal_id;
|
|
|
|
int spatial_id;
|
|
|
|
|
2021-10-12 10:23:58 +02:00
|
|
|
uint8_t gm_invalid[AV1_NUM_REF_FRAMES];
|
2020-09-09 05:39:55 +02:00
|
|
|
uint8_t gm_type[AV1_NUM_REF_FRAMES];
|
|
|
|
int32_t gm_params[AV1_NUM_REF_FRAMES][6];
|
2020-11-03 16:34:28 +02:00
|
|
|
|
|
|
|
uint8_t skip_mode_frame_idx[2];
|
2020-11-03 16:54:44 +02:00
|
|
|
|
2020-11-25 22:02:56 +02:00
|
|
|
AV1RawFilmGrainParams film_grain;
|
|
|
|
|
2020-11-03 16:54:44 +02:00
|
|
|
uint8_t coded_lossless;
|
2024-04-13 21:05:23 +02:00
|
|
|
|
|
|
|
// OrderHint for this frame.
|
|
|
|
uint8_t order_hint;
|
|
|
|
// RefFrameSignBias[] used when decoding this frame.
|
|
|
|
uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME];
|
|
|
|
// OrderHints[] when this is the current frame, otherwise
|
|
|
|
// SavedOrderHints[s][] when is the reference frame in slot s.
|
|
|
|
uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME];
|
2024-04-27 17:22:05 +02:00
|
|
|
|
|
|
|
// force_integer_mv value at the end of the frame header parsing.
|
|
|
|
// This is not the same as the syntax element value in
|
|
|
|
// raw_frame_header because the specification parsing tables
|
|
|
|
// override the value on intra frames.
|
|
|
|
uint8_t force_integer_mv;
|
2020-09-09 05:39:55 +02:00
|
|
|
} 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;
|
2023-05-20 00:54:49 +02:00
|
|
|
AVPacket *pkt;
|
2020-09-09 05:39:55 +02:00
|
|
|
|
2024-02-21 00:09:12 +02:00
|
|
|
AVBufferRef *seq_data_ref;
|
2022-08-04 11:59:16 +02:00
|
|
|
AV1RawOBU *seq_ref; ///< RefStruct reference backing raw_seq
|
2020-09-09 05:39:55 +02:00
|
|
|
AV1RawSequenceHeader *raw_seq;
|
2022-08-04 11:59:16 +02:00
|
|
|
AV1RawOBU *header_ref; ///< RefStruct reference backing raw_frame_header
|
2020-09-09 05:39:55 +02:00
|
|
|
AV1RawFrameHeader *raw_frame_header;
|
|
|
|
TileGroupInfo *tile_group_info;
|
2023-03-06 01:32:23 +02:00
|
|
|
|
2022-08-04 11:59:16 +02:00
|
|
|
AV1RawOBU *cll_ref; ///< RefStruct reference backing cll
|
2023-03-06 01:32:23 +02:00
|
|
|
AV1RawMetadataHDRCLL *cll;
|
2022-08-04 11:59:16 +02:00
|
|
|
AV1RawOBU *mdcv_ref; ///< RefStruct reference backing mdcv
|
2023-03-06 01:32:23 +02:00
|
|
|
AV1RawMetadataHDRMDCV *mdcv;
|
2024-02-23 22:24:32 +02:00
|
|
|
DOVIContext dovi;
|
2023-03-06 01:32:23 +02:00
|
|
|
AVFifo *itut_t35_fifo;
|
|
|
|
|
2020-09-09 05:39:55 +02:00
|
|
|
uint16_t tile_num;
|
|
|
|
uint16_t tg_start;
|
|
|
|
uint16_t tg_end;
|
|
|
|
|
2020-11-15 23:55:41 +02:00
|
|
|
int operating_point_idc;
|
|
|
|
|
2020-09-09 05:39:55 +02:00
|
|
|
AV1Frame ref[AV1_NUM_REF_FRAMES];
|
|
|
|
AV1Frame cur_frame;
|
|
|
|
|
2023-11-10 22:11:44 +02:00
|
|
|
int nb_unit; ///< The index of the next OBU to be processed.
|
|
|
|
int start_unit; ///< The index of the first OBU of the current frame.
|
2023-05-20 00:54:49 +02:00
|
|
|
|
2020-11-15 23:55:41 +02:00
|
|
|
// AVOptions
|
|
|
|
int operating_point;
|
2020-09-09 05:39:55 +02:00
|
|
|
} AV1DecContext;
|
|
|
|
|
|
|
|
#endif /* AVCODEC_AV1DEC_H */
|