40#define XEVD_PARAM_BAD_NAME -1
41#define XEVD_PARAM_BAD_VALUE -2
43#define EVC_NAL_HEADER_SIZE 2
72 memset(cdsc, 0,
sizeof(XEVD_CDSC));
78 cdsc->threads = XEVD_MAX_TASK_CNT;
94 if (bs_size == XEVD_NAL_UNIT_LENGTH_BYTE) {
95 ret = xevd_info((
void *)bs, XEVD_NAL_UNIT_LENGTH_BYTE, 1, &info);
96 if (XEVD_FAILED(ret)) {
124 ret = xevd_config(xectx->
id, XEVD_CFG_GET_CODED_WIDTH, &avctx->
coded_width, &
size);
125 if (XEVD_FAILED(ret)) {
131 if (XEVD_FAILED(ret)) {
136 ret = xevd_config(xectx->
id, XEVD_CFG_GET_WIDTH, &avctx->
width, &
size);
137 if (XEVD_FAILED(ret)) {
142 ret = xevd_config(xectx->
id, XEVD_CFG_GET_HEIGHT, &avctx->
height, &
size);
143 if (XEVD_FAILED(ret)) {
148 ret = xevd_config(xectx->
id, XEVD_CFG_GET_COLOR_SPACE, &color_space, &
size);
149 if (XEVD_FAILED(ret)) {
153 switch(color_space) {
154 case XEVD_CS_YCBCR400_10LE:
157 case XEVD_CS_YCBCR420_10LE:
160 case XEVD_CS_YCBCR422_10LE:
163 case XEVD_CS_YCBCR444_10LE:
173 ret = xevd_config(xectx->
id, XEVD_CFG_GET_MAX_CODING_DELAY, &avctx->
has_b_frames, &
size);
174 if (XEVD_FAILED(ret)) {
193 if (imgb->cs != XEVD_CS_YCBCR420_10LE) {
198 if (imgb->w[0] != avctx->
width || imgb->h[0] != avctx->
height) {
211 imgb->w[0], imgb->h[0]);
226 XEVD_CDSC *cdsc = &(xectx->
cdsc);
232 xectx->
id = xevd_create(&(xectx->
cdsc),
NULL);
295 frame->pkt_dts = imgb->ts[XEVD_TS_DTS];
296 frame->pts = imgb->ts[XEVD_TS_PTS];
319 XEVD_IMGB *imgb =
NULL;
351 while(pkt_au->
size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) {
352 memset(&stat, 0,
sizeof(XEVD_STAT));
355 if (nalu_size == 0) {
362 bs_read_pos += XEVD_NAL_UNIT_LENGTH_BYTE;
364 bitb.addr = pkt_au->
data + bs_read_pos;
365 bitb.ssize = nalu_size;
366 bitb.pdata[0] = pkt_au;
367 bitb.ts[XEVD_TS_DTS] = pkt_au->
dts;
370 xevd_ret = xevd_decode(xectx->
id, &bitb, &stat);
371 if (XEVD_FAILED(xevd_ret)) {
378 bs_read_pos += nalu_size;
380 if (stat.nalu_type == XEVD_NUT_SPS) {
389 if (stat.read != nalu_size)
390 av_log(avctx,
AV_LOG_INFO,
"Different reading of bitstream (in:%d, read:%d)\n,", nalu_size, stat.read);
393 if (stat.fnum >= 0) {
395 xevd_ret = xevd_pull(xectx->
id, &imgb);
397 if (XEVD_FAILED(xevd_ret)) {
398 av_log(avctx,
AV_LOG_ERROR,
"Failed to pull the decoded image (xevd error code: %d, frame#=%d)\n", xevd_ret, stat.fnum);
403 }
else if (xevd_ret == XEVD_OK_FRM_DELAYED) {
404 if(bs_read_pos == pkt_au->
size) {
409 if(bs_read_pos == pkt_au->
size) {
416 if (stat.stype == XEVD_ST_I) {
427 xevd_ret = xevd_pull(xectx->
id, &imgb);
429 if (xevd_ret == XEVD_ERR_UNEXPECTED) {
433 }
else if (XEVD_FAILED(xevd_ret)) {
434 av_log(avctx,
AV_LOG_ERROR,
"Failed to pull the decoded image (xevd error code: %d)\n", xevd_ret);
461 xevd_delete(xectx->
id);
483 .p.wrapper_name =
"libxevd",
const FFCodec ff_libxevd_decoder
Libavcodec external API header.
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_CAP_SETS_FRAME_PROPS
Codec handles output frame properties internally instead of letting the internal logic derive them fr...
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt)
Set various frame properties from the provided packet.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_image_copy(uint8_t *const dst_data[4], const int dst_linesizes[4], const uint8_t *const 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_PICTURE_TYPE_I
Intra.
static atomic_int cpu_count
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void get_conf(AVCodecContext *avctx, XEVD_CDSC *cdsc)
The function populates the XEVD_CDSC structure.
static av_cold int libxevd_init(AVCodecContext *avctx)
Initialize decoder Create a decoder instance and allocate all the needed resources.
static int libxevd_return_frame(AVCodecContext *avctx, AVFrame *frame, XEVD_IMGB *imgb, AVPacket **pkt_au)
static int libxevd_image_copy(struct AVCodecContext *avctx, XEVD_IMGB *imgb, struct AVFrame *frame)
Copy image in imgb to frame.
static int libxevd_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Decode frame with decoupled packet/frame dataflow.
static int export_stream_params(const XevdContext *xectx, AVCodecContext *avctx)
static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size, AVCodecContext *avctx)
Read NAL unit length.
static av_cold int libxevd_close(AVCodecContext *avctx)
Destroy decoder.
#define FFSWAP(type, a, b)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
const AVProfile ff_evc_profiles[]
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int coded_width
Bitstream width / height, may be different from width/height e.g.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
The structure stores all the states associated with the instance of Xeve MPEG-5 EVC decoder.