Commit 1a708780 authored by Derek Buitenhuis's avatar Derek Buitenhuis

Merge commit '89923e41'

* commit '89923e41':
  lavu: add a framework for handling hwaccel frames
Merged-by: 's avatarDerek Buitenhuis <derek.buitenhuis@gmail.com>
parents 26abd514 89923e41
...@@ -17,6 +17,8 @@ API changes, most recent first: ...@@ -17,6 +17,8 @@ API changes, most recent first:
2016-xx-xx - lavu 55.18.0 2016-xx-xx - lavu 55.18.0
xxxxxxx buffer.h - Add av_buffer_pool_init2(). 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.
-------- 8< --------- FFmpeg 3.0 was cut here -------- 8< --------- -------- 8< --------- FFmpeg 3.0 was cut here -------- 8< ---------
......
...@@ -31,6 +31,7 @@ HEADERS = adler32.h \ ...@@ -31,6 +31,7 @@ HEADERS = adler32.h \
frame.h \ frame.h \
hash.h \ hash.h \
hmac.h \ hmac.h \
hwcontext.h \
imgutils.h \ imgutils.h \
intfloat.h \ intfloat.h \
intreadwrite.h \ intreadwrite.h \
...@@ -108,6 +109,7 @@ OBJS = adler32.o \ ...@@ -108,6 +109,7 @@ OBJS = adler32.o \
frame.o \ frame.o \
hash.o \ hash.o \
hmac.o \ hmac.o \
hwcontext.o \
imgutils.o \ imgutils.o \
integer.o \ integer.o \
intmath.o \ intmath.o \
......
...@@ -429,6 +429,14 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) ...@@ -429,6 +429,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 */ /* duplicate extended data */
if (src->extended_data != src->data) { if (src->extended_data != src->data) {
int ch = src->channels; int ch = src->channels;
...@@ -490,6 +498,8 @@ void av_frame_unref(AVFrame *frame) ...@@ -490,6 +498,8 @@ void av_frame_unref(AVFrame *frame)
av_buffer_unref(&frame->qp_table_buf); av_buffer_unref(&frame->qp_table_buf);
#endif #endif
av_buffer_unref(&frame->hw_frames_ctx);
get_frame_defaults(frame); get_frame_defaults(frame);
} }
......
...@@ -421,6 +421,12 @@ typedef struct AVFrame { ...@@ -421,6 +421,12 @@ typedef struct AVFrame {
enum AVChromaLocation chroma_location; enum AVChromaLocation chroma_location;
/**
* For hwaccel-format frames, this should be a reference to the
* AVHWFramesContext describing the frame.
*/
AVBufferRef *hw_frames_ctx;
/** /**
* frame timestamp estimated using various heuristics, in stream time base * frame timestamp estimated using various heuristics, in stream time base
* Code outside libavutil should access this field using: * Code outside libavutil should access this field using:
......
This diff is collapsed.
This diff is collapsed.
/*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; 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