Go to the documentation of this file.
24 #include <sys/types.h>
84 #define INPUT_DEQUEUE_TIMEOUT_US 8000
85 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000
86 #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000
114 switch (color_standard) {
130 switch (color_standard) {
153 switch (color_transfer) {
179 static const struct {
256 AVMediaCodecBuffer *
buffer = opaque;
263 "Releasing output buffer %zd (%p) ts=%"PRId64
" on free() [%d pending]\n",
268 if (
ctx->delay_flush)
321 if (!
frame->buf[0]) {
339 "Wrapping output buffer %zd (%p) ts=%"PRId64
" [%d pending]\n",
397 "Frame: width=%d stride=%d height=%d slice-height=%d "
398 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s "
399 "destination linesizes=%d,%d,%d\n" ,
401 s->crop_top,
s->crop_bottom,
s->crop_left,
s->crop_right,
s->codec_name,
404 switch (
s->color_format) {
422 s->color_format,
s->color_format);
438 #define AMEDIAFORMAT_GET_INT32(name, key, mandatory) do { \
440 if (ff_AMediaFormat_getInt32(s->format, key, &value)) { \
442 } else if (mandatory) { \
443 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", key, format); \
444 ret = AVERROR_EXTERNAL; \
455 int color_standard = 0;
456 int color_transfer = 0;
475 s->stride =
s->stride > 0 ?
s->stride :
s->width;
479 if (strstr(
s->codec_name,
"OMX.Nvidia.") &&
s->slice_height == 0) {
480 s->slice_height =
FFALIGN(
s->height, 16);
481 }
else if (strstr(
s->codec_name,
"OMX.SEC.avc.dec")) {
482 s->slice_height = avctx->
height;
484 }
else if (
s->slice_height == 0) {
485 s->slice_height =
s->height;
502 width =
s->crop_right + 1 -
s->crop_left;
503 height =
s->crop_bottom + 1 -
s->crop_top;
508 if (
s->display_width &&
s->display_height) {
520 if (color_standard) {
530 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
531 "resulting dimensions width=%d height=%d\n",
532 s->crop_top,
s->crop_bottom,
s->crop_left,
s->crop_right,
547 s->output_buffer_count = 0;
554 s->current_input_buffer = -1;
582 s->current_input_buffer = -1;
591 if (device_ctx->
hwctx) {
599 if (!
s->surface && user_ctx && user_ctx->
surface) {
611 if (!
s->codec_name) {
619 av_log(avctx,
AV_LOG_ERROR,
"Failed to create media decoder for type %s and name %s\n", mime,
s->codec_name);
628 "Failed to configure codec %s (status = %d) with format %s\n",
640 "Failed to start codec %s (status = %d) with format %s\n",
651 "Failed to configure context\n");
670 int need_draining = 0;
680 "until all output buffers have been released\n");
688 if (
s->draining &&
s->eos) {
692 while (offset < pkt->
size || (need_draining && !
s->draining)) {
693 ssize_t
index =
s->current_input_buffer;
706 s->current_input_buffer = -1;
735 "Queued empty EOS input buffer %zd with flags=%d\n",
index,
flags);
752 "Queued input buffer %zd size=%zd ts=%"PRIi64
"\n",
index,
size,
pts);
772 if (
s->draining &&
s->eos) {
780 }
else if (
s->output_buffer_count == 0 || !wait) {
784 output_dequeue_timeout_us = 0;
790 " offset=%" PRIi32
" size=%" PRIi32
" ts=%" PRIi64
792 info.presentationTimeUs,
info.flags);
817 s->output_buffer_count++;
858 "while draining remaining frames, output will probably lack frames\n",
859 output_dequeue_timeout_us / 1000);
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
#define FF_ENABLE_DEPRECATION_WARNINGS
void * hwaccel_context
Hardware accelerator context.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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
enum AVColorSpace colorspace
YUV colorspace type.
AVColorTransferCharacteristic
Color Transfer Characteristic.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
void * surface
android/view/Surface handle, to be filled by the user.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_HWDEVICE_TYPE_MEDIACODEC
AVBufferRef * av_buffer_create(uint8_t *data, buffer_size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
#define atomic_fetch_sub(object, operand)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
static enum AVPixelFormat pix_fmts[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define atomic_load(object)
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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 holds a reference to a android/view/Surface object that will be used as output by the ...
Rational number (pair of numerator and denominator).
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_PRI_BT2020
ITU-R BT2020.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AVERROR_EXTERNAL
Generic error in an external library.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define AV_LOG_INFO
Standard information.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
AVColorSpace
YUV colorspace type.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
void * surface
android/view/Surface object reference.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
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
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
main external API structure.
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
#define atomic_fetch_add(object, operand)
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
#define FF_DISABLE_DEPRECATION_WARNINGS
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.
This structure stores compressed data.
int width
picture width / height.
#define flags(name, subs,...)
#define atomic_init(obj, value)
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVColorRange
Visual content value range.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.