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
100 static const struct {
177 AVMediaCodecBuffer *
buffer = opaque;
184 "Releasing output buffer %zd (%p) ts=%"PRId64
" on free() [%d pending]\n",
189 if (
ctx->delay_flush)
238 if (!
frame->buf[0]) {
256 "Wrapping output buffer %zd (%p) ts=%"PRId64
" [%d pending]\n",
314 "Frame: width=%d stride=%d height=%d slice-height=%d "
315 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s "
316 "destination linesizes=%d,%d,%d\n" ,
318 s->crop_top,
s->crop_bottom,
s->crop_left,
s->crop_right,
s->codec_name,
321 switch (
s->color_format) {
339 s->color_format,
s->color_format);
355 #define AMEDIAFORMAT_GET_INT32(name, key, mandatory) do { \
357 if (ff_AMediaFormat_getInt32(s->format, key, &value)) { \
359 } else if (mandatory) { \
360 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", key, format); \
361 ret = AVERROR_EXTERNAL; \
389 s->stride =
s->stride > 0 ?
s->stride :
s->width;
393 if (strstr(
s->codec_name,
"OMX.Nvidia.") &&
s->slice_height == 0) {
394 s->slice_height =
FFALIGN(
s->height, 16);
395 }
else if (strstr(
s->codec_name,
"OMX.SEC.avc.dec")) {
396 s->slice_height = avctx->
height;
398 }
else if (
s->slice_height == 0) {
399 s->slice_height =
s->height;
416 width =
s->crop_right + 1 -
s->crop_left;
417 height =
s->crop_bottom + 1 -
s->crop_top;
422 if (
s->display_width &&
s->display_height) {
430 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
431 "resulting dimensions width=%d height=%d\n",
432 s->crop_top,
s->crop_bottom,
s->crop_left,
s->crop_right,
447 s->output_buffer_count = 0;
454 s->current_input_buffer = -1;
482 s->current_input_buffer = -1;
491 if (device_ctx->
hwctx) {
499 if (!
s->surface && user_ctx && user_ctx->
surface) {
511 if (!
s->codec_name) {
519 av_log(avctx,
AV_LOG_ERROR,
"Failed to create media decoder for type %s and name %s\n", mime,
s->codec_name);
528 "Failed to configure codec (status = %d) with format %s\n",
540 "Failed to start codec (status = %d) with format %s\n",
551 "Failed to configure context\n");
570 int need_draining = 0;
572 ssize_t
index =
s->current_input_buffer;
581 "until all output buffers have been released\n");
589 if (
s->draining &&
s->eos) {
593 while (offset < pkt->
size || (need_draining && !
s->draining)) {
606 s->current_input_buffer = -1;
631 "Queued input buffer %zd size=%zd ts=%"PRIi64
"\n",
index,
size,
pts);
648 "Queued input buffer %zd size=%zd ts=%"PRIi64
"\n",
index,
size,
pts);
668 if (
s->draining &&
s->eos) {
676 }
else if (
s->output_buffer_count == 0 || !wait) {
680 output_dequeue_timeout_us = 0;
686 " offset=%" PRIi32
" size=%" PRIi32
" ts=%" PRIi64
688 info.presentationTimeUs,
info.flags);
713 s->output_buffer_count++;
754 "while draining remaining frames, output will probably lack frames\n",
755 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
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.
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).
@ AV_HWDEVICE_TYPE_MEDIACODEC
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define atomic_fetch_sub(object, operand)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#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
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)
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
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).
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.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
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.
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
#define FF_ARRAY_ELEMS(a)
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.
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)
#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)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.