24 #include <sys/types.h>
83 #define INPUT_DEQUEUE_TIMEOUT_US 8000
84 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000
85 #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000
138 color_format, color_format);
176 AVMediaCodecBuffer *
buffer = opaque;
217 buffer =
av_mallocz(
sizeof(AVMediaCodecBuffer));
231 if (!frame->
buf[0]) {
240 buffer->index =
index;
300 "Frame: width=%d stride=%d height=%d slice-height=%d "
301 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s\n"
302 "destination linesizes=%d,%d,%d\n" ,
387 av_log(avctx,
AV_LOG_ERROR,
"Could not get %s from format %s\n",
"slice-height", format);
395 }
else if (strstr(s->
codec_name,
"OMX.SEC.avc.dec")) {
402 av_log(avctx,
AV_LOG_ERROR,
"Could not get %s from format %s\n",
"color-format", format);
431 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
432 "resulting dimensions width=%d height=%d\n",
479 if (user_ctx && user_ctx->
surface) {
508 "Failed to configure codec (status = %d) with format %s\n",
520 "Failed to start codec (status = %d) with format %s\n",
531 "Failed to configure context\n");
552 int need_draining = 0;
566 "until all output buffers have been released\n");
570 if (pkt->
size == 0) {
578 while (offset < pkt->size || (need_draining && !s->
draining)) {
608 av_log(avctx,
AV_LOG_ERROR,
"Failed to queue input empty buffer (status = %d)\n", status);
619 memcpy(data, pkt->
data + offset, size);
642 output_dequeue_timeout_us = 0;
650 " offset=%" PRIi32
" size=%" PRIi32
" ts=%" PRIi64
651 " flags=%" PRIu32
"\n", index, info.
offset, info.
size,
718 "while draining remaining frames, output will probably lack frames\n",
719 output_dequeue_timeout_us / 1000);
762 .
name =
"mediacodec",
769 .
name =
"mediacodec",
776 .
name =
"mediacodec",
783 .
name =
"mediacodec",
790 .
name =
"mediacodec",
797 .
name =
"mediacodec",
This structure holds a reference to a android/view/Surface object that will be used as output by the ...
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
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 describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
#define AV_LOG_WARNING
Something somehow does not look correct.
Memory handling functions.
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.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * hwaccel_context
Hardware accelerator context.
timestamp utils, mostly useful for debugging/logging purposes
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
enum AVPixelFormat pix_fmt
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define atomic_load(object)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
uint64_t output_buffer_count
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)
static const uint8_t offset[127][2]
const char * name
Name of the hardware accelerated codec.
int width
picture width / height.
GLsizei GLboolean const GLfloat * value
preferred ID for MPEG-1/2 video decoding
#define FF_ARRAY_ELEMS(a)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define atomic_fetch_add(object, operand)
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static AVRational av_make_q(int num, int den)
Create an AVRational.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static const char * format
static enum AVPixelFormat pix_fmts[]
hardware decoding through MediaCodec
static int64_t pts
Global timestamp for the audio frames.
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.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
common internal and external API header
#define FF_ENABLE_DEPRECATION_WARNINGS
void * surface
android/view/Surface object reference.
#define atomic_init(obj, value)
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.