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)
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",
629 s->codec_name, status,
desc);
640 "Failed to start codec %s (status = %d) with format %s\n",
641 s->codec_name, status,
desc);
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;
730 av_log(avctx,
AV_LOG_ERROR,
"Failed to queue input empty buffer (status = %d)\n", status);
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
817 s->output_buffer_count++;
858 "while draining remaining frames, output will probably lack frames\n",
859 output_dequeue_timeout_us / 1000);
static const char *const format[]
Libavcodec external API header.
#define flags(name, subs,...)
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
#define atomic_load(object)
#define atomic_init(obj, value)
#define atomic_fetch_sub(object, operand)
#define atomic_fetch_add(object, operand)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
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.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
@ AV_HWDEVICE_TYPE_MEDIACODEC
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
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.
common internal API header
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
AVColorRange
Visual content value range.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ 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...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
AVColorPrimaries
Chromaticity coordinates of the source primaries.
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
@ AVCOL_PRI_BT2020
ITU-R BT2020.
AVColorTransferCharacteristic
Color Transfer Characteristic.
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
#define FF_ARRAY_ELEMS(a)
uint8_t * data
The data buffer.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
enum AVColorSpace colorspace
YUV colorspace type.
void * hwaccel_context
Hardware accelerator context.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
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).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
attribute_deprecated int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
enum AVColorPrimaries color_primaries
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
enum AVColorSpace colorspace
YUV colorspace type.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVColorTransferCharacteristic color_trc
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
This structure holds a reference to a android/view/Surface object that will be used as output by the ...
void * surface
android/view/Surface object reference.
void * surface
android/view/Surface handle, to be filled by the user.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Rational number (pair of numerator and denominator).
timestamp utils, mostly useful for debugging/logging purposes
static const uint8_t offset[127][2]