24 #include "libavutil/pixdesc.h"
36 frame->
flags &= ~flags;
54 if (x0 < 0 || y0 < 0) {
154 int min_poc = INT_MAX;
155 int i, j, min_idx,
ret;
162 if (frame->
poc < min_poc) {
163 min_poc = frame->
poc;
186 for (j = 0; j < 3; j++) {
216 for (i = ctb_addr_ts; i < ctb_count; i++)
242 for (list_idx = 0; list_idx < nb_list; list_idx++) {
269 for (i = 0; i < sh->
nb_refs[list_idx]; i++) {
278 rpl->
ref[i] = rpl_tmp.
ref[idx];
283 memcpy(rpl, &rpl_tmp,
sizeof(*rpl));
303 if ((ref->
poc & LtMask) == poc)
311 if (ref->
poc == poc || (ref->
poc & LtMask) == poc)
317 "Could not find ref with POC %d\n", poc);
324 frame->
flags |= flag;
338 for (i = 0; frame->
frame->
buf[i]; i++)
362 int poc,
int ref_flag)
413 if (!short_rps->
used[i])
415 else if (i < short_rps->num_negative_pics)
426 for (i = 0; i < long_rps->
nb_refs; i++) {
427 int poc = long_rps->
poc[i];
445 int prev_poc_lsb = s->
pocTid0 % max_poc_lsb;
446 int prev_poc_msb = s->
pocTid0 - prev_poc_lsb;
449 if ((poc_lsb < prev_poc_lsb) && ((prev_poc_lsb - poc_lsb) >= max_poc_lsb / 2))
450 poc_msb = prev_poc_msb + max_poc_lsb;
451 else if ((poc_lsb > prev_poc_lsb) && ((poc_lsb - prev_poc_lsb) > (max_poc_lsb / 2)))
452 poc_msb = prev_poc_msb - max_poc_lsb;
454 poc_msb = prev_poc_msb;
462 return poc_msb + poc_lsb;
474 ret += !!rps->
used[i];
476 ret += !!rps->
used[i];
480 for (i = 0; i < long_rps->
nb_refs; i++)
481 ret += !!long_rps->
used[i];
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
RefPicList * ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame, int x0, int y0)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static HEVCFrame * find_ref_idx(HEVCContext *s, int poc)
struct HEVCFrame * ref[MAX_REFS]
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint16_t seq_decode
Sequence counters for decoded and output frames, so that old frames are output first after a POC rese...
int ff_hevc_frame_nb_refs(HEVCContext *s)
Get the number of candidate references for the current frame.
static HEVCFrame * alloc_frame(HEVCContext *s)
AVBufferPool * rpl_tab_pool
candidate references for the current frame
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
Compute POC of the current frame and return it.
Multithreading support functions.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
struct HEVCSPS::@63 temporal_layer[MAX_SUB_LAYERS]
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
void ff_hevc_clear_refs(HEVCContext *s)
Mark all frames in DPB as unused for reference.
#define HEVC_FRAME_FLAG_SHORT_REF
int slice_idx
number of the slice being currently decoded
static void mark_ref(HEVCFrame *frame, int flag)
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
uint16_t depth_minus1
number of bits in the component minus 1
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int log2_max_poc_lsb
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVBufferRef * rpl_tab_buf
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
unsigned int log2_ctb_size
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
uint16_t sequence
A sequence counter, so that old frames are output first after a POC reset.
#define FF_ARRAY_ELEMS(a)
AVBufferRef * tab_mvf_buf
uint8_t * data
The data buffer.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define HEVC_FRAME_FLAG_LONG_REF
struct HEVCFrame * collocated_ref
static int add_candidate_ref(HEVCContext *s, RefPicList *list, int poc, int ref_flag)
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
static int init_slice_rpl(HEVCContext *s)
static void flush(AVCodecContext *avctx)
int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush)
Find next frame in output order and put a reference to it in frame.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static HEVCFrame * generate_missing_ref(HEVCContext *s, int poc)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int * ctb_addr_rs_to_ts
CtbAddrRSToTS.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FF_THREAD_FRAME
Decode more than one frame at once.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum NALUnitType nal_unit_type
int ff_hevc_frame_rps(HEVCContext *s)
Construct the reference picture sets for the current frame.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
int size
Size of data in bytes.
common internal api header.
AVBufferPool * tab_mvf_pool
#define HEVC_FRAME_FLAG_OUTPUT
#define AVERROR_INVALIDDATA
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.