Commit 89923e41 authored by Anton Khirnov's avatar Anton Khirnov

lavu: add a framework for handling hwaccel frames

parent 721a4efc
......@@ -15,6 +15,8 @@ API changes, most recent first:
2016-xx-xx - lavu 55.6.0
xxxxxxx buffer.h - Add av_buffer_pool_init2().
xxxxxxx hwcontext.h - Add a new installed header hwcontext.h with a new API
for handling hwaccel frames.
2016-xx-xx - xxxxxxx - lavf 57.3.0 - avformat.h
Add AVFormatContext.opaque, io_open and io_close, allowing custom IO
......
......@@ -23,6 +23,7 @@ HEADERS = adler32.h \
file.h \
frame.h \
hmac.h \
hwcontext.h \
imgutils.h \
intfloat.h \
intreadwrite.h \
......@@ -78,6 +79,7 @@ OBJS = adler32.o \
float_dsp.o \
frame.o \
hmac.o \
hwcontext.o \
imgutils.o \
intmath.o \
lfg.o \
......
......@@ -251,6 +251,14 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
}
}
if (src->hw_frames_ctx) {
dst->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
if (!dst->hw_frames_ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
/* duplicate extended data */
if (src->extended_data != src->data) {
int ch = av_get_channel_layout_nb_channels(src->channel_layout);
......@@ -303,6 +311,9 @@ void av_frame_unref(AVFrame *frame)
for (i = 0; i < frame->nb_extended_buf; i++)
av_buffer_unref(&frame->extended_buf[i]);
av_freep(&frame->extended_buf);
av_buffer_unref(&frame->hw_frames_ctx);
get_frame_defaults(frame);
}
......
......@@ -354,6 +354,12 @@ typedef struct AVFrame {
enum AVColorSpace colorspace;
enum AVChromaLocation chroma_location;
/**
* For hwaccel-format frames, this should be a reference to the
* AVHWFramesContext describing the frame.
*/
AVBufferRef *hw_frames_ctx;
} AVFrame;
/**
......
This diff is collapsed.
This diff is collapsed.
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVUTIL_HWCONTEXT_INTERNAL_H
#define AVUTIL_HWCONTEXT_INTERNAL_H
#include <stddef.h>
#include "buffer.h"
#include "hwcontext.h"
#include "frame.h"
#include "pixfmt.h"
typedef struct HWContextType {
enum AVHWDeviceType type;
const char *name;
/**
* An array of pixel formats supported by the AVHWFramesContext instances
* Terminated by AV_PIX_FMT_NONE.
*/
const enum AVPixelFormat *pix_fmts;
/**
* size of the public hardware-specific context,
* i.e. AVHWDeviceContext.hwctx
*/
size_t device_hwctx_size;
/**
* size of the private data, i.e.
* AVHWDeviceInternal.priv
*/
size_t device_priv_size;
/**
* size of the public frame pool hardware-specific context,
* i.e. AVHWFramesContext.hwctx
*/
size_t frames_hwctx_size;
/**
* size of the private data, i.e.
* AVHWFramesInternal.priv
*/
size_t frames_priv_size;
int (*device_init)(AVHWDeviceContext *ctx);
void (*device_uninit)(AVHWDeviceContext *ctx);
int (*frames_init)(AVHWFramesContext *ctx);
void (*frames_uninit)(AVHWFramesContext *ctx);
int (*frames_get_buffer)(AVHWFramesContext *ctx, AVFrame *frame);
int (*transfer_get_formats)(AVHWFramesContext *ctx,
enum AVHWFrameTransferDirection dir,
enum AVPixelFormat **formats);
int (*transfer_data_to)(AVHWFramesContext *ctx, AVFrame *dst,
const AVFrame *src);
int (*transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst,
const AVFrame *src);
} HWContextType;
struct AVHWDeviceInternal {
const HWContextType *hw_type;
void *priv;
};
struct AVHWFramesInternal {
const HWContextType *hw_type;
void *priv;
AVBufferPool *pool_internal;
};
#endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment