1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit 'ad0c9f2d5d81e22207c6ccecc426bf7306acc327'

* commit 'ad0c9f2d5d81e22207c6ccecc426bf7306acc327':
  lavc: move AVFrame.hwaccel_picture_private to Picture.

Conflicts:
	libavcodec/avcodec.h
	libavcodec/mpegvideo.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-03-08 19:35:37 +01:00
commit fee484edaf
7 changed files with 28 additions and 22 deletions

View File

@ -1410,12 +1410,12 @@ typedef struct AVFrame {
*/ */
int64_t reordered_opaque; int64_t reordered_opaque;
#if FF_API_AVFRAME_LAVC
/** /**
* hardware accelerator private data (FFmpeg-allocated) * @deprecated this field is unused
* - encoding: unused
* - decoding: Set by libavcodec
*/ */
void *hwaccel_picture_private; attribute_deprecated void *hwaccel_picture_private;
#endif
/** /**
* the AVCodecContext which ff_thread_get_buffer() was last called on * the AVCodecContext which ff_thread_get_buffer() was last called on

View File

@ -278,7 +278,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
const unsigned mb_count = h->mb_width * h->mb_height; const unsigned mb_count = h->mb_width * h->mb_height;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
const Picture *current_picture = h->cur_pic_ptr; const Picture *current_picture = h->cur_pic_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
DXVA_Slice_H264_Short *slice = NULL; DXVA_Slice_H264_Short *slice = NULL;
uint8_t *dxva_data, *current, *end; uint8_t *dxva_data, *current, *end;
unsigned dxva_size; unsigned dxva_size;
@ -373,7 +373,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
{ {
const H264Context *h = avctx->priv_data; const H264Context *h = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private;
if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
return -1; return -1;
@ -398,7 +398,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
const H264Context *h = avctx->priv_data; const H264Context *h = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
const Picture *current_picture = h->cur_pic_ptr; const Picture *current_picture = h->cur_pic_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
unsigned position; unsigned position;
if (ctx_pic->slice_count >= MAX_SLICES) if (ctx_pic->slice_count >= MAX_SLICES)
@ -426,7 +426,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
h->cur_pic_ptr->f.hwaccel_picture_private; h->cur_pic_ptr->hwaccel_picture_private;
int ret; int ret;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)

View File

@ -151,7 +151,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
const struct MpegEncContext *s = avctx->priv_data; const struct MpegEncContext *s = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->f.hwaccel_picture_private; s->current_picture_ptr->hwaccel_picture_private;
const int is_field = s->picture_structure != PICT_FRAME; const int is_field = s->picture_structure != PICT_FRAME;
const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); const unsigned mb_count = s->mb_width * (s->mb_height >> is_field);
uint8_t *dxva_data, *current, *end; uint8_t *dxva_data, *current, *end;
@ -210,7 +210,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
const struct MpegEncContext *s = avctx->priv_data; const struct MpegEncContext *s = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->f.hwaccel_picture_private; s->current_picture_ptr->hwaccel_picture_private;
if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
return -1; return -1;
@ -230,7 +230,7 @@ static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx,
{ {
const struct MpegEncContext *s = avctx->priv_data; const struct MpegEncContext *s = avctx->priv_data;
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->f.hwaccel_picture_private; s->current_picture_ptr->hwaccel_picture_private;
unsigned position; unsigned position;
if (ctx_pic->slice_count >= MAX_SLICES) if (ctx_pic->slice_count >= MAX_SLICES)
@ -250,7 +250,7 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
{ {
struct MpegEncContext *s = avctx->priv_data; struct MpegEncContext *s = avctx->priv_data;
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->f.hwaccel_picture_private; s->current_picture_ptr->hwaccel_picture_private;
int ret; int ret;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)

View File

@ -162,7 +162,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
const VC1Context *v = avctx->priv_data; const VC1Context *v = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
const MpegEncContext *s = &v->s; const MpegEncContext *s = &v->s;
struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private;
DXVA_SliceInfo *slice = &ctx_pic->si; DXVA_SliceInfo *slice = &ctx_pic->si;
@ -217,7 +217,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
{ {
const VC1Context *v = avctx->priv_data; const VC1Context *v = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
return -1; return -1;
@ -236,7 +236,7 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx,
{ {
const VC1Context *v = avctx->priv_data; const VC1Context *v = avctx->priv_data;
const Picture *current_picture = v->s.current_picture_ptr; const Picture *current_picture = v->s.current_picture_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
if (ctx_pic->bitstream_size > 0) if (ctx_pic->bitstream_size > 0)
return -1; return -1;
@ -257,7 +257,7 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx,
static int dxva2_vc1_end_frame(AVCodecContext *avctx) static int dxva2_vc1_end_frame(AVCodecContext *avctx)
{ {
VC1Context *v = avctx->priv_data; VC1Context *v = avctx->priv_data;
struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
int ret; int ret;
if (ctx_pic->bitstream_size <= 0) if (ctx_pic->bitstream_size <= 0)

View File

@ -252,7 +252,7 @@ static void free_frame_buffer(MpegEncContext *s, Picture *pic)
ff_thread_release_buffer(s->avctx, &pic->f); ff_thread_release_buffer(s->avctx, &pic->f);
else else
avcodec_default_release_buffer(s->avctx, &pic->f); avcodec_default_release_buffer(s->avctx, &pic->f);
av_freep(&pic->f.hwaccel_picture_private); av_freep(&pic->hwaccel_picture_private);
} }
int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize) int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize)
@ -288,10 +288,10 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
int r, ret; int r, ret;
if (s->avctx->hwaccel) { if (s->avctx->hwaccel) {
assert(!pic->f.hwaccel_picture_private); assert(!pic->hwaccel_picture_private);
if (s->avctx->hwaccel->priv_data_size) { if (s->avctx->hwaccel->priv_data_size) {
pic->f.hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size); pic->hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
if (!pic->f.hwaccel_picture_private) { if (!pic->hwaccel_picture_private) {
av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n"); av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1; return -1;
} }
@ -308,7 +308,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
if (r < 0 || !pic->f.type || !pic->f.data[0]) { if (r < 0 || !pic->f.type || !pic->f.data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n", av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
r, pic->f.type, pic->f.data[0]); r, pic->f.type, pic->f.data[0]);
av_freep(&pic->f.hwaccel_picture_private); av_freep(&pic->hwaccel_picture_private);
return -1; return -1;
} }

View File

@ -146,6 +146,10 @@ typedef struct Picture{
void *owner2; ///< pointer to the context that allocated this picture void *owner2; ///< pointer to the context that allocated this picture
int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change) int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change)
int period_since_free; ///< "cycles" since this Picture has been freed int period_since_free; ///< "cycles" since this Picture has been freed
/**
* hardware accelerator private data
*/
void *hwaccel_picture_private;
} Picture; } Picture;
/** /**

View File

@ -132,7 +132,9 @@
#ifndef FF_API_LLS_PRIVATE #ifndef FF_API_LLS_PRIVATE
#define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 53) #define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 53)
#endif #endif
#ifndef FF_API_AVFRAME_LAVC
#define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 53)
#endif
/** /**
* @} * @}