38#include "config_components.h"
54#if CONFIG_APV_VULKAN_HWACCEL
69 int coded_width =
FFALIGN(
header->frame_info.frame_width, 16);
70 int coded_height =
FFALIGN(
header->frame_info.frame_height, 16);
172 ff_cbs_fragment_reset(&apv->
au);
173 ff_cbs_flush(apv->
cbc);
180 ff_cbs_fragment_free(&apv->
au);
181 ff_cbs_close(&apv->
cbc);
193 const uint16_t *qmatrix)
199 memset(
coeff, 0, 64 *
sizeof(int16_t));
222 int tile_index = job / nb_components;
223 int comp_index = job % nb_components;
225 int sub_w_shift = comp_index == 0 ? 0 : pix_fmt_desc->
log2_chroma_w;
226 int sub_h_shift = comp_index == 0 ? 0 : pix_fmt_desc->
log2_chroma_h;
230 int tile_y = tile_index /
tile_info->tile_cols;
231 int tile_x = tile_index %
tile_info->tile_cols;
233 int tile_start_x =
tile_info->col_starts[tile_x];
234 int tile_start_y =
tile_info->row_starts[tile_y];
236 int tile_width =
tile_info->col_starts[tile_x + 1] - tile_start_x;
237 int tile_height =
tile_info->row_starts[tile_y + 1] - tile_start_y;
242 int blk_mb_width = 2 >> sub_w_shift;
243 int blk_mb_height = 2 >> sub_h_shift;
262 tile->tile_header.tile_data_size[comp_index]);
271 int qp =
tile->tile_header.tile_qp[comp_index];
277 for (
int y = 0; y < 8; y++) {
278 for (
int x = 0; x < 8; x++)
284 for (
int mb_y = 0; mb_y < tile_mb_height; mb_y++) {
285 for (
int mb_x = 0; mb_x < tile_mb_width; mb_x++) {
286 for (
int blk_y = 0; blk_y < blk_mb_height; blk_y++) {
287 for (
int blk_x = 0; blk_x < blk_mb_width; blk_x++) {
288 int frame_y = (tile_start_y +
291 int frame_x = (tile_start_x +
297 frame_y * frame_pitch + 2 * frame_x;
300 block_start, frame_pitch,
301 &gbc, &entropy_state,
316 "Decoded tile %d component %d: %dx%d MBs starting at (%d,%d)\n",
317 tile_index, comp_index, tile_mb_width, tile_mb_height,
318 tile_start_x, tile_start_y);
324 "Decode error in tile %d component %d.\n",
325 tile_index, comp_index);
338 for (
i = 0; start_mb < frame_width_in_mbs;
i++) {
346 for (
i = 0; start_mb < frame_height_in_mbs;
i++) {
402 for (
int j = 0; j <
desc->nb_components; j++) {
405 err =
hwaccel->decode_slice(avctx,
tile->tile_data[j],
406 tile->tile_header.tile_data_size[j]);
412 err =
hwaccel->end_frame(avctx);
423 input,
NULL, job_count);
428 "Decode errors in %d tile components.\n", err);
446 for (
int i = 0;
i <
md->metadata_count;
i++) {
460 for (
int j = 0; j < 3; j++) {
530 "Stream contains additional non-primary frames "
531 "which will be ignored by the decoder.\n");
543 "Stream contains PBUs with unknown types "
544 "which will be ignored by the decoder.\n");
558 ff_cbs_fragment_reset(&apv->
au);
561 if (!err && !
frame->buf[0])
578 err = ff_cbs_read_packet(apv->
cbc, &apv->
au, apv->
pkt);
580 ff_cbs_fragment_reset(&apv->
au);
592 }
while (err ==
AVERROR(EAGAIN));
625#if CONFIG_APV_VULKAN_HWACCEL
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
const FFCodec ff_apv_decoder
static int apv_decode_block(AVCodecContext *avctx, void *output, ptrdiff_t pitch, GetBitContext *gbc, APVEntropyState *entropy_state, int bit_depth, int qp_shift, const uint16_t *qmatrix)
static AVOnce apv_entropy_once
static av_cold void apv_decode_flush(AVCodecContext *avctx)
static av_cold int apv_decode_init(AVCodecContext *avctx)
static enum AVPixelFormat get_pixel_format(AVCodecContext *avctx, enum AVPixelFormat pix_fmt)
static int apv_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
static av_cold void apv_entropy_build_decode_lut(void)
static enum AVPixelFormat apv_format_table[5][4]
static int apv_decode_tile_component(AVCodecContext *avctx, void *data, int job, int thread)
static int apv_decode_metadata(AVCodecContext *avctx, AVFrame *frame, const APVRawMetadata *md)
APVVLCLUT ff_apv_decode_lut
static void apv_derive_tile_info(APVDerivedTileInfo *ti, const APVRawFrameHeader *fh)
static int apv_decode(AVCodecContext *avctx, AVFrame *output, APVRawFrame *input)
static av_cold int apv_decode_close(AVCodecContext *avctx)
static int apv_receive_frame(AVCodecContext *avctx, AVFrame *frame)
static const CodedBitstreamUnitType apv_decompose_unit_types[]
static int apv_decode_check_format(AVCodecContext *avctx, const APVRawFrameHeader *header)
int ff_apv_entropy_decode_block(int16_t *restrict coeff, GetBitContext *restrict gbc, APVEntropyState *restrict state)
Entropy decode a single 8x8 block to coefficients.
void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
Build the decoder VLC look-up tables.
static const uint8_t apv_level_scale[6]
static av_cold void close(AVCodecParserContext *s)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static int FUNC tile_info(CodedBitstreamContext *ctx, RWContext *rw, APVRawTileInfo *current, const APVRawFrameHeader *fh)
static int FUNC tile(CodedBitstreamContext *ctx, RWContext *rw, APVRawTile *current, int tile_idx, uint32_t tile_size)
#define i(width, name, range_min, range_max)
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define CODEC_LONG_NAME(str)
int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, AVContentLightMetadata **clm)
Wrapper around av_content_light_metadata_create_side_data(), which rejects side data overridden by th...
int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm)
Wrapper around av_mastering_display_metadata_create_side_data(), which rejects side data overridden b...
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
static enum AVPixelFormat pix_fmt
void(* flush)(AVBSFContext *ctx)
int(* init)(AVBSFContext *ctx)
#define atomic_fetch_add_explicit(object, operand, order)
#define atomic_load_explicit(object, order)
#define atomic_store_explicit(object, desired, order)
#define atomic_init(obj, value)
static const char * hwaccel
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
@ AVDISCARD_ALL
discard all
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
#define HWACCEL_VULKAN(codec)
static const int level_scale[2][6]
@ APV_PBU_NON_PRIMARY_FRAME
@ APV_PBU_ACCESS_UNIT_INFORMATION
av_cold void ff_apv_dsp_init(APVDSPContext *dsp)
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
common internal api header.
Multithreading API for decoders.
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
static enum AVPixelFormat pix_fmts[]
#define LOCAL_ALIGNED_32(t, v,...)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV444P12
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GRAY12
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
void(* decode_transquant)(void *output, ptrdiff_t pitch, const int16_t *input, const int16_t *qmatrix, int bit_depth, int qp_shift)
APVRawFrame * cur_raw_frame
uint8_t warned_unknown_pbu_types
CodedBitstreamFragment au
uint8_t warned_additional_frames
enum AVPixelFormat pix_fmt
CodedBitstreamContext * cbc
APVDerivedTileInfo tile_info
void * hwaccel_picture_private
uint16_t col_starts[APV_MAX_TILE_COLS+1]
uint16_t row_starts[APV_MAX_TILE_ROWS+1]
APVRawFrameHeader frame_header
APVRawTile tile[APV_MAX_TILE_COUNT]
uint8_t q_matrix[APV_MAX_NUM_COMP][APV_TR_SIZE][APV_TR_SIZE]
uint32_t tile_width_in_mbs
uint32_t tile_height_in_mbs
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int level
Encoding level descriptor.
enum AVColorSpace colorspace
YUV colorspace type.
int refs
number of reference frames
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
int flags
AV_CODEC_FLAG_*.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
int coded_width
Bitstream width / height, may be different from width/height e.g.
struct AVCodecInternal * internal
Private context used for internal data.
enum AVDiscard skip_frame
Skip decoding for selected frames.
int is_copy
When using frame-threaded decoding, this field is set for the first worker thread (e....
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
uint8_t nb_components
The number of components each pixel has, (1-4)
Rational number (pair of numerator and denominator).
const CodedBitstreamUnitType * decompose_unit_types
Array of unit types which should be decomposed when reading.
int nb_decompose_unit_types
Length of the decompose_unit_types array.
Coded bitstream fragment structure, combining one or more units.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
int nb_units
Number of units in this fragment.
Coded bitstream unit structure.
void * content
Pointer to the decomposed form of this unit.
CodedBitstreamUnitType type
Codec-specific type of this unit.
#define avpriv_request_sample(...)
static const double coeff[2][5]