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 {
139 color_format, color_format);
177 AVMediaCodecBuffer *
buffer = opaque;
218 buffer =
av_mallocz(
sizeof(AVMediaCodecBuffer));
224 buffer->released = 0;
232 if (!frame->
buf[0]) {
241 buffer->index =
index;
295 "Frame: width=%d stride=%d height=%d slice-height=%d "
296 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s\n"
297 "destination linesizes=%d,%d,%d\n" ,
382 av_log(avctx,
AV_LOG_ERROR,
"Could not get %s from format %s\n",
"slice-height", format);
390 }
else if (strstr(s->
codec_name,
"OMX.SEC.avc.dec")) {
397 av_log(avctx,
AV_LOG_ERROR,
"Could not get %s from format %s\n",
"color-format", format);
426 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
427 "resulting dimensions width=%d height=%d\n",
474 if (user_ctx && user_ctx->
surface) {
503 "Failed to configure codec (status = %d) with format %s\n",
515 "Failed to start codec (status = %d) with format %s\n",
526 "Failed to configure context\n");
547 int need_draining = 0;
561 "until all output buffers have been released\n");
565 if (pkt->
size == 0) {
573 while (offset < pkt->size || (need_draining && !s->
draining)) {
603 av_log(avctx,
AV_LOG_ERROR,
"Failed to queue input empty buffer (status = %d)\n", status);
614 memcpy(data, pkt->
data + offset, size);
637 output_dequeue_timeout_us = 0;
645 " offset=%" PRIi32
" size=%" PRIi32
" ts=%" PRIi64
646 " flags=%" PRIu32
"\n", index, info.
offset, info.
size,
713 "while draining remaining frames, output will probably lack frames\n",
714 output_dequeue_timeout_us / 1000);
757 .
name =
"mediacodec",
764 .
name =
"mediacodec",
771 .
name =
"mediacodec",
778 .
name =
"mediacodec",
785 .
name =
"mediacodec",
This structure holds a reference to a android/view/Surface object that will be used as output by the ...
#define avpriv_atomic_int_add_and_fetch
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.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define avpriv_atomic_int_get
#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.
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
#define FF_ARRAY_ELEMS(a)
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#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 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.