FFmpeg
libxevd.c
Go to the documentation of this file.
1 /*
2  * libxevd decoder
3  * EVC (MPEG-5 Essential Video Coding) decoding using XEVD MPEG-5 EVC decoder library
4  *
5  * Copyright (C) 2021 Dawid Kozinski <d.kozinski@samsung.com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include <stddef.h>
25 
26 #include <xevd.h>
27 
28 #include "libavutil/internal.h"
29 #include "libavutil/common.h"
30 #include "libavutil/pixdesc.h"
31 #include "libavutil/pixfmt.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/cpu.h"
34 
35 #include "avcodec.h"
36 #include "codec_internal.h"
37 #include "profiles.h"
38 #include "decode.h"
39 
40 #define XEVD_PARAM_BAD_NAME -1
41 #define XEVD_PARAM_BAD_VALUE -2
42 
43 #define EVC_NAL_HEADER_SIZE 2 /* byte */
44 
45 /**
46  * The structure stores all the states associated with the instance of Xeve MPEG-5 EVC decoder
47  */
48 typedef struct XevdContext {
49  XEVD id; // XEVD instance identifier @see xevd.h
50  XEVD_CDSC cdsc; // decoding parameters @see xevd.h
51 
52  // If end of stream occurs it is required "flushing" (aka draining) the codec,
53  // as the codec might buffer multiple frames or packets internally.
54  int draining_mode; // The flag is set if codec enters draining mode.
55 
56  AVPacket *pkt; // access unit (a set of NAL units that are consecutive in decoding order and containing exactly one encoded image)
57 } XevdContext;
58 
59 /**
60  * The function populates the XEVD_CDSC structure.
61  * XEVD_CDSC contains all decoder parameters that should be initialized before its use.
62  *
63  * @param[in] avctx codec context
64  * @param[out] cdsc contains all decoder parameters that should be initialized before its use
65  *
66  */
67 static void get_conf(AVCodecContext *avctx, XEVD_CDSC *cdsc)
68 {
69  int cpu_count = av_cpu_count();
70 
71  /* clear XEVS_CDSC structure */
72  memset(cdsc, 0, sizeof(XEVD_CDSC));
73 
74  /* init XEVD_CDSC */
75  if (avctx->thread_count <= 0)
76  cdsc->threads = (cpu_count < XEVD_MAX_TASK_CNT) ? cpu_count : XEVD_MAX_TASK_CNT;
77  else if (avctx->thread_count > XEVD_MAX_TASK_CNT)
78  cdsc->threads = XEVD_MAX_TASK_CNT;
79  else
80  cdsc->threads = avctx->thread_count;
81 }
82 
83 /**
84  * Read NAL unit length
85  * @param bs input data (bitstream)
86  * @return the length of NAL unit on success, 0 value on failure
87  */
88 static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size, AVCodecContext *avctx)
89 {
90  uint32_t len = 0;
91  XEVD_INFO info;
92  int ret;
93 
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)) {
97  av_log(avctx, AV_LOG_ERROR, "Cannot get bitstream information\n");
98  return 0;
99  }
100  len = info.nalu_len;
101  if (len == 0) {
102  av_log(avctx, AV_LOG_ERROR, "Invalid bitstream size! [%d]\n", bs_size);
103  return 0;
104  }
105  }
106 
107  return len;
108 }
109 
110 /**
111  * @param[in] xectx the structure that stores all the state associated with the instance of Xeve MPEG-5 EVC decoder
112  * @param[out] avctx codec context
113  * @return 0 on success, negative value on failure
114  */
115 static int export_stream_params(const XevdContext *xectx, AVCodecContext *avctx)
116 {
117  int ret;
118  int size;
119  int color_space;
120 
121  avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
122 
123  size = 4;
124  ret = xevd_config(xectx->id, XEVD_CFG_GET_CODED_WIDTH, &avctx->coded_width, &size);
125  if (XEVD_FAILED(ret)) {
126  av_log(avctx, AV_LOG_ERROR, "Failed to get coded_width\n");
127  return AVERROR_EXTERNAL;
128  }
129 
130  ret = xevd_config(xectx->id, XEVD_CFG_GET_CODED_HEIGHT, &avctx->coded_height, &size);
131  if (XEVD_FAILED(ret)) {
132  av_log(avctx, AV_LOG_ERROR, "Failed to get coded_height\n");
133  return AVERROR_EXTERNAL;
134  }
135 
136  ret = xevd_config(xectx->id, XEVD_CFG_GET_WIDTH, &avctx->width, &size);
137  if (XEVD_FAILED(ret)) {
138  av_log(avctx, AV_LOG_ERROR, "Failed to get width\n");
139  return AVERROR_EXTERNAL;
140  }
141 
142  ret = xevd_config(xectx->id, XEVD_CFG_GET_HEIGHT, &avctx->height, &size);
143  if (XEVD_FAILED(ret)) {
144  av_log(avctx, AV_LOG_ERROR, "Failed to get height\n");
145  return AVERROR_EXTERNAL;
146  }
147 
148  ret = xevd_config(xectx->id, XEVD_CFG_GET_COLOR_SPACE, &color_space, &size);
149  if (XEVD_FAILED(ret)) {
150  av_log(avctx, AV_LOG_ERROR, "Failed to get color_space\n");
151  return AVERROR_EXTERNAL;
152  }
153  switch(color_space) {
154  case XEVD_CS_YCBCR400_10LE:
155  avctx->pix_fmt = AV_PIX_FMT_GRAY10LE;
156  break;
157  case XEVD_CS_YCBCR420_10LE:
159  break;
160  case XEVD_CS_YCBCR422_10LE:
162  break;
163  case XEVD_CS_YCBCR444_10LE:
165  break;
166  default:
167  av_log(avctx, AV_LOG_ERROR, "Unknown color space\n");
168  avctx->pix_fmt = AV_PIX_FMT_NONE;
169  return AVERROR_INVALIDDATA;
170  }
171 
172  // the function returns sps->num_reorder_pics
173  ret = xevd_config(xectx->id, XEVD_CFG_GET_MAX_CODING_DELAY, &avctx->has_b_frames, &size);
174  if (XEVD_FAILED(ret)) {
175  av_log(avctx, AV_LOG_ERROR, "Failed to get max_coding_delay\n");
176  return AVERROR_EXTERNAL;
177  }
178 
179  return 0;
180 }
181 
182 /**
183  * @brief Copy image in imgb to frame.
184  *
185  * @param avctx codec context
186  * @param[in] imgb
187  * @param[out] frame
188  * @return 0 on success, negative value on failure
189  */
190 static int libxevd_image_copy(struct AVCodecContext *avctx, XEVD_IMGB *imgb, struct AVFrame *frame)
191 {
192  int ret;
193  if (imgb->cs != XEVD_CS_YCBCR420_10LE) {
194  av_log(avctx, AV_LOG_ERROR, "Not supported pixel format: %s\n", av_get_pix_fmt_name(avctx->pix_fmt));
195  return AVERROR_INVALIDDATA;
196  }
197 
198  if (imgb->w[0] != avctx->width || imgb->h[0] != avctx->height) { // stream resolution changed
199  if (ff_set_dimensions(avctx, imgb->w[0], imgb->h[0]) < 0) {
200  av_log(avctx, AV_LOG_ERROR, "Cannot set new dimension\n");
201  return AVERROR_INVALIDDATA;
202  }
203  }
204 
205  ret = ff_get_buffer(avctx, frame, 0);
206  if (ret < 0)
207  return ret;
208 
209  av_image_copy(frame->data, frame->linesize, (const uint8_t **)imgb->a,
210  imgb->s, avctx->pix_fmt,
211  imgb->w[0], imgb->h[0]);
212 
213  return 0;
214 }
215 
216 /**
217  * Initialize decoder
218  * Create a decoder instance and allocate all the needed resources
219  *
220  * @param avctx codec context
221  * @return 0 on success, negative error code on failure
222  */
224 {
225  XevdContext *xectx = avctx->priv_data;
226  XEVD_CDSC *cdsc = &(xectx->cdsc);
227 
228  /* read configurations and set values for created descriptor (XEVD_CDSC) */
229  get_conf(avctx, cdsc);
230 
231  /* create decoder */
232  xectx->id = xevd_create(&(xectx->cdsc), NULL);
233  if (xectx->id == NULL) {
234  av_log(avctx, AV_LOG_ERROR, "Cannot create XEVD encoder\n");
235  return AVERROR_EXTERNAL;
236  }
237 
238  xectx->draining_mode = 0;
239  xectx->pkt = av_packet_alloc();
240  if (!xectx->pkt) {
241  av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory for AVPacket\n");
242  return AVERROR(ENOMEM);
243  }
244 
245  return 0;
246 }
247 
249  XEVD_IMGB *imgb, AVPacket **pkt_au)
250 {
251  AVPacket *pkt_au_imgb = (AVPacket*)imgb->pdata[0];
252  int ret;
253 
254  if (!pkt_au_imgb) {
255  av_log(avctx, AV_LOG_ERROR, "Invalid data needed to fill frame properties\n");
256 
257  if (pkt_au)
258  av_packet_free(pkt_au);
260 
261  imgb->release(imgb);
262  imgb = NULL;
263 
264  return AVERROR_INVALIDDATA;
265  }
266 
267  // got frame
268  ret = libxevd_image_copy(avctx, imgb, frame);
269  if (ret < 0) {
270  av_log(avctx, AV_LOG_ERROR, "Image copying error\n");
271 
272  av_packet_free(&pkt_au_imgb);
274 
275  imgb->release(imgb);
276  imgb = NULL;
277 
278  return ret;
279  }
280 
281  // use ff_decode_frame_props_from_pkt() to fill frame properties
282  ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt_au_imgb);
283  if (ret < 0) {
284  av_log(avctx, AV_LOG_ERROR, "ff_decode_frame_props_from_pkt error\n");
285 
286  av_packet_free(&pkt_au_imgb);
288 
289  imgb->release(imgb);
290  imgb = NULL;
291 
292  return ret;
293  }
294 
295  frame->pkt_dts = imgb->ts[XEVD_TS_DTS];
296  frame->pts = imgb->ts[XEVD_TS_PTS];
297 
298  av_packet_free(&pkt_au_imgb);
299 
300  // xevd_pull uses pool of objects of type XEVD_IMGB.
301  // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed
302  imgb->release(imgb);
303  imgb = NULL;
304 
305  return 0;
306 }
307 /**
308  * Decode frame with decoupled packet/frame dataflow
309  *
310  * @param avctx codec context
311  * @param[out] frame decoded frame
312  *
313  * @return 0 on success, negative error code on failure
314  */
316 {
317  XevdContext *xectx = avctx->priv_data;
318  AVPacket *pkt = xectx->pkt;
319  XEVD_IMGB *imgb = NULL;
320 
321  int xevd_ret = 0;
322  int ret = 0;
323 
324  // obtain access unit (input data) - a set of NAL units that are consecutive in decoding order and containing exactly one encoded image
325  ret = ff_decode_get_packet(avctx, pkt);
326  if (ret < 0 && ret != AVERROR_EOF) {
328 
329  return ret;
330  } else if(ret == AVERROR_EOF && xectx->draining_mode == 0) { // End of stream situations. Enter draining mode
331 
332  xectx->draining_mode = 1;
334  }
335 
336  if (pkt->size > 0) {
337  int bs_read_pos = 0;
338  XEVD_STAT stat;
339  XEVD_BITB bitb;
340  int nalu_size;
341  AVPacket *pkt_au = av_packet_alloc();
342  imgb = NULL;
343 
344  if (!pkt_au) {
346  return AVERROR(ENOMEM);
347  }
348  FFSWAP(AVPacket*, pkt_au, xectx->pkt);
349 
350  // get all nal units from AU
351  while(pkt_au->size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) {
352  memset(&stat, 0, sizeof(XEVD_STAT));
353 
354  nalu_size = read_nal_unit_length(pkt_au->data + bs_read_pos, XEVD_NAL_UNIT_LENGTH_BYTE, avctx);
355  if (nalu_size == 0) {
356  av_log(avctx, AV_LOG_ERROR, "Invalid bitstream\n");
357  av_packet_free(&pkt_au);
359 
360  return ret;
361  }
362  bs_read_pos += XEVD_NAL_UNIT_LENGTH_BYTE;
363 
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;
368 
369  /* main decoding block */
370  xevd_ret = xevd_decode(xectx->id, &bitb, &stat);
371  if (XEVD_FAILED(xevd_ret)) {
372  av_log(avctx, AV_LOG_ERROR, "Failed to decode bitstream\n");
373  av_packet_free(&pkt_au);
374 
375  return AVERROR_EXTERNAL;
376  }
377 
378  bs_read_pos += nalu_size;
379 
380  if (stat.nalu_type == XEVD_NUT_SPS) { // EVC stream parameters changed
381  if ((ret = export_stream_params(xectx, avctx)) != 0) {
382  av_log(avctx, AV_LOG_ERROR, "Failed to export stream params\n");
383  av_packet_free(&pkt_au);
384 
385  return ret;
386  }
387  }
388 
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);
391 
392  // stat.fnum - has negative value if the decoded data is not frame
393  if (stat.fnum >= 0) {
394 
395  xevd_ret = xevd_pull(xectx->id, &imgb); // The function returns a valid image only if the return code is XEVD_OK
396 
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);
399 
400  av_packet_free(&pkt_au);
401 
402  return AVERROR_EXTERNAL;
403  } else if (xevd_ret == XEVD_OK_FRM_DELAYED) {
404  if(bs_read_pos == pkt_au->size) {
405  return AVERROR(EAGAIN);
406  }
407  } else { // XEVD_OK
408  if (!imgb) {
409  if(bs_read_pos == pkt_au->size) {
410  av_log(avctx, AV_LOG_ERROR, "Invalid decoded image data\n");
411 
412  av_packet_free(&pkt_au);
413  return AVERROR(EAGAIN);
414  }
415  } else {
416  if (stat.stype == XEVD_ST_I) {
417  frame->pict_type = AV_PICTURE_TYPE_I;
418  frame->flags |= AV_FRAME_FLAG_KEY;
419  }
420  return libxevd_return_frame(avctx, frame, imgb, &pkt_au);
421  }
422  }
423  }
424  }
425  } else { // decoder draining mode handling
426 
427  xevd_ret = xevd_pull(xectx->id, &imgb);
428 
429  if (xevd_ret == XEVD_ERR_UNEXPECTED) { // draining process completed
430  av_log(avctx, AV_LOG_DEBUG, "Draining process completed\n");
431 
432  return AVERROR_EOF;
433  } else if (XEVD_FAILED(xevd_ret)) { // handle all other errors
434  av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded image (xevd error code: %d)\n", xevd_ret);
435 
436  return AVERROR_EXTERNAL;
437  } else { // XEVD_OK
438  if (!imgb) {
439  av_log(avctx, AV_LOG_ERROR, "Invalid decoded image data\n");
440 
441  return AVERROR_EXTERNAL;
442  }
443 
444  return libxevd_return_frame(avctx, frame, imgb, NULL);
445  }
446  }
447 
448  return ret;
449 }
450 
451 /**
452  * Destroy decoder
453  *
454  * @param avctx codec context
455  * @return 0 on success
456  */
458 {
459  XevdContext *xectx = avctx->priv_data;
460  if (xectx->id) {
461  xevd_delete(xectx->id);
462  xectx->id = NULL;
463  }
464 
465  xectx->draining_mode = 0;
466  av_packet_free(&xectx->pkt);
467 
468  return 0;
469 }
470 
472  .p.name = "evc",
473  CODEC_LONG_NAME("EVC / MPEG-5 Essential Video Coding (EVC)"),
474  .p.type = AVMEDIA_TYPE_VIDEO,
475  .p.id = AV_CODEC_ID_EVC,
476  .init = libxevd_init,
478  .close = libxevd_close,
479  .priv_data_size = sizeof(XevdContext),
480  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
482  .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles),
483  .p.wrapper_name = "libxevd",
486 };
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:428
ff_decode_get_packet
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
Definition: decode.c:237
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
cpu_count
static atomic_int cpu_count
Definition: cpu.c:53
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
XevdContext
The structure stores all the states associated with the instance of Xeve MPEG-5 EVC decoder.
Definition: libxevd.c:48
ff_libxevd_decoder
const FFCodec ff_libxevd_decoder
Definition: libxevd.c:471
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
pixdesc.h
AVPacket::data
uint8_t * data
Definition: packet.h:533
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
FFCodec
Definition: codec_internal.h:126
read_nal_unit_length
static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size, AVCodecContext *avctx)
Read NAL unit length.
Definition: libxevd.c:88
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:94
AV_PIX_FMT_GRAY10LE
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
Definition: pixfmt.h:321
XevdContext::pkt
AVPacket * pkt
Definition: libxevd.c:56
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: packet.c:74
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:130
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1583
libxevd_return_frame
static int libxevd_return_frame(AVCodecContext *avctx, AVFrame *frame, XEVD_IMGB *imgb, AVPacket **pkt_au)
Definition: libxevd.c:248
ff_decode_frame_props_from_pkt
int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt)
Set various frame properties from the provided packet.
Definition: decode.c:1401
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:633
AV_PIX_FMT_YUV420P10LE
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:156
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:625
AVCodecContext::has_b_frames
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition: avcodec.h:723
AV_CODEC_ID_EVC
@ AV_CODEC_ID_EVC
Definition: codec_id.h:321
AV_CODEC_CAP_OTHER_THREADS
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:124
info
MIPS optimizations info
Definition: mips.txt:2
ff_evc_profiles
const AVProfile ff_evc_profiles[]
Definition: profiles.c:199
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
decode.h
libxevd_close
static av_cold int libxevd_close(AVCodecContext *avctx)
Destroy decoder.
Definition: libxevd.c:457
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:271
AV_PIX_FMT_YUV444P10LE
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:162
if
if(ret)
Definition: filter_design.txt:179
libxevd_init
static av_cold int libxevd_init(AVCodecContext *avctx)
Initialize decoder Create a decoder instance and allocate all the needed resources.
Definition: libxevd.c:223
NULL
#define NULL
Definition: coverity.c:32
export_stream_params
static int export_stream_params(const XevdContext *xectx, AVCodecContext *avctx)
Definition: libxevd.c:115
get_conf
static void get_conf(AVCodecContext *avctx, XEVD_CDSC *cdsc)
The function populates the XEVD_CDSC structure.
Definition: libxevd.c:67
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
profiles.h
libxevd_receive_frame
static int libxevd_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Decode frame with decoupled packet/frame dataflow.
Definition: libxevd.c:315
libxevd_image_copy
static int libxevd_image_copy(struct AVCodecContext *avctx, XEVD_IMGB *imgb, struct AVFrame *frame)
Copy image in imgb to frame.
Definition: libxevd.c:190
av_cpu_count
int av_cpu_count(void)
Definition: cpu.c:211
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1575
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:534
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
codec_internal.h
cpu.h
AV_PIX_FMT_YUV422P10LE
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:158
FF_CODEC_CAP_SETS_FRAME_PROPS
#define FF_CODEC_CAP_SETS_FRAME_PROPS
Codec handles output frame properties internally instead of letting the internal logic derive them fr...
Definition: codec_internal.h:77
size
int size
Definition: twinvq_data.h:10344
XevdContext::cdsc
XEVD_CDSC cdsc
Definition: libxevd.c:50
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:532
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: packet.c:63
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
XevdContext::id
XEVD id
Definition: libxevd.c:49
internal.h
common.h
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:606
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
len
int len
Definition: vorbis_enc_data.h:426
AVCodecContext::height
int height
Definition: avcodec.h:618
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:657
avcodec.h
ret
ret
Definition: filter_design.txt:187
pixfmt.h
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVCodecContext
main external API structure.
Definition: avcodec.h:445
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:292
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:633
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
AVPacket
This structure stores compressed data.
Definition: packet.h:510
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
XevdContext::draining_mode
int draining_mode
Definition: libxevd.c:54
AV_CODEC_CAP_AVOID_PROBING
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:138
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
av_image_copy
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.
Definition: imgutils.c:422
av_get_pix_fmt_name
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.
Definition: pixdesc.c:2885