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",
253 "Wrapping output buffer %zd (%p) ts=%"PRId64
" [%d pending]\n",
305 "Frame: width=%d stride=%d height=%d slice-height=%d "
306 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s "
307 "destination linesizes=%d,%d,%d\n" ,
309 s->crop_top,
s->crop_bottom,
s->crop_left,
s->crop_right,
s->codec_name,
312 switch (
s->color_format) {
330 s->color_format,
s->color_format);
346 #define AMEDIAFORMAT_GET_INT32(name, key, mandatory) do { \
348 if (ff_AMediaFormat_getInt32(s->format, key, &value)) { \
350 } else if (mandatory) { \
351 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", key, format); \
352 ret = AVERROR_EXTERNAL; \
363 int color_standard = 0;
364 int color_transfer = 0;
383 s->stride =
s->stride > 0 ?
s->stride :
s->width;
387 if (strstr(
s->codec_name,
"OMX.Nvidia.") &&
s->slice_height == 0) {
388 s->slice_height =
FFALIGN(
s->height, 16);
389 }
else if (strstr(
s->codec_name,
"OMX.SEC.avc.dec")) {
390 s->slice_height = avctx->
height;
392 }
else if (
s->slice_height == 0) {
393 s->slice_height =
s->height;
411 if (!(
s->crop_right &&
s->crop_bottom) &&
s->use_ndk_codec)
414 if (
s->crop_right &&
s->crop_bottom) {
415 width =
s->crop_right + 1 -
s->crop_left;
416 height =
s->crop_bottom + 1 -
s->crop_top;
432 if (
s->display_width &&
s->display_height) {
444 if (color_standard) {
454 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
455 "resulting dimensions width=%d height=%d\n",
456 s->crop_top,
s->crop_bottom,
s->crop_left,
s->crop_right,
471 s->output_buffer_count = 0;
478 s->current_input_buffer = -1;
506 s->current_input_buffer = -1;
515 if (device_ctx->
hwctx) {
523 if (!
s->surface && user_ctx && user_ctx->
surface) {
535 if (!
s->codec_name) {
538 if (!
s->use_ndk_codec) {
558 av_log(avctx,
AV_LOG_ERROR,
"Failed to create media decoder for type %s and name %s\n", mime,
s->codec_name);
567 "Failed to configure codec %s (status = %d) with format %s\n",
579 "Failed to start codec %s (status = %d) with format %s\n",
590 "Failed to configure context\n");
609 int need_draining = 0;
619 "until all output buffers have been released\n");
627 if (
s->draining &&
s->eos) {
631 while (offset < pkt->
size || (need_draining && !
s->draining)) {
632 ssize_t
index =
s->current_input_buffer;
645 s->current_input_buffer = -1;
674 "Queued empty EOS input buffer %zd with flags=%d\n",
index,
flags);
691 "Queued input buffer %zd size=%zd ts=%"PRIi64
"\n",
index,
size,
pts);
711 if (
s->draining &&
s->eos) {
719 }
else if (
s->output_buffer_count == 0 || !wait) {
723 output_dequeue_timeout_us = 0;
729 " offset=%" PRIi32
" size=%" PRIi32
" ts=%" PRIi64
731 info.presentationTimeUs,
info.flags);
756 s->output_buffer_count++;
797 "while draining remaining frames, output will probably lack frames\n",
798 output_dequeue_timeout_us / 1000);
807 if (
s->draining &&
s->eos)
826 if (!
s->surface || !
s->delay_flush ||
atomic_load(&
s->refcount) == 1) {
enum AVColorTransferCharacteristic color_trc
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
void * hwaccel_context
Legacy hardware accelerator context.
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVPixelFormat
Pixel format.
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.
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.
enum AVColorPrimaries color_primaries
enum AVColorSpace colorspace
YUV colorspace type.
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.
@ AV_HWDEVICE_TYPE_MEDIACODEC
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#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
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
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
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 expressed.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
#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.
void * native_window
Pointer to ANativeWindow.
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...
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
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)
char * av_strdup(const char *s)
Duplicate a string.
This structure stores compressed data.
int width
picture width / height.
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#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.