Commit b7fe35c9 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  h264: deMpegEncContextize

Conflicts:
	libavcodec/dxva2_h264.c
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_mb_template.c
	libavcodec/h264_parser.c
	libavcodec/h264_ps.c
	libavcodec/h264_refs.c
	libavcodec/h264_sei.c
	libavcodec/svq3.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents ddbbfd95 2c541554
...@@ -932,8 +932,8 @@ static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *a ...@@ -932,8 +932,8 @@ static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *a
} else { } else {
av_log(avctx, AV_LOG_VERBOSE, av_log(avctx, AV_LOG_VERBOSE,
"CrystalHD: parser picture type %d\n", "CrystalHD: parser picture type %d\n",
h->s.picture_structure); h->picture_structure);
pic_type = h->s.picture_structure; pic_type = h->picture_structure;
} }
} else { } else {
av_log(avctx, AV_LOG_WARNING, av_log(avctx, AV_LOG_WARNING,
......
...@@ -76,7 +76,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, ...@@ -76,7 +76,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx,
return result; return result;
} }
int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s, int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic,
const void *pp, unsigned pp_size, const void *pp, unsigned pp_size,
const void *qm, unsigned qm_size, const void *qm, unsigned qm_size,
int (*commit_bs_si)(AVCodecContext *, int (*commit_bs_si)(AVCodecContext *,
...@@ -90,7 +90,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s, ...@@ -90,7 +90,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s,
int result; int result;
if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder, if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
ff_dxva2_get_surface(s->current_picture_ptr), ff_dxva2_get_surface(pic),
NULL))) { NULL))) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n"); av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
return -1; return -1;
...@@ -146,7 +146,5 @@ end: ...@@ -146,7 +146,5 @@ end:
result = -1; result = -1;
} }
if (!result)
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
return result; return result;
} }
...@@ -44,15 +44,14 @@ static void fill_picture_entry(DXVA_PicEntry_H264 *pic, ...@@ -44,15 +44,14 @@ static void fill_picture_entry(DXVA_PicEntry_H264 *pic,
static void fill_picture_parameters(struct dxva_context *ctx, const H264Context *h, static void fill_picture_parameters(struct dxva_context *ctx, const H264Context *h,
DXVA_PicParams_H264 *pp) DXVA_PicParams_H264 *pp)
{ {
const MpegEncContext *s = &h->s; const Picture *current_picture = h->cur_pic_ptr;
const Picture *current_picture = s->current_picture_ptr;
int i, j; int i, j;
memset(pp, 0, sizeof(*pp)); memset(pp, 0, sizeof(*pp));
/* Configure current picture */ /* Configure current picture */
fill_picture_entry(&pp->CurrPic, fill_picture_entry(&pp->CurrPic,
ff_dxva2_get_surface_index(ctx, current_picture), ff_dxva2_get_surface_index(ctx, current_picture),
s->picture_structure == PICT_BOTTOM_FIELD); h->picture_structure == PICT_BOTTOM_FIELD);
/* Configure the set of references */ /* Configure the set of references */
pp->UsedForReferenceFlags = 0; pp->UsedForReferenceFlags = 0;
pp->NonExistingFrameFlags = 0; pp->NonExistingFrameFlags = 0;
...@@ -88,13 +87,13 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context ...@@ -88,13 +87,13 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
} }
} }
pp->wFrameWidthInMbsMinus1 = s->mb_width - 1; pp->wFrameWidthInMbsMinus1 = h->mb_width - 1;
pp->wFrameHeightInMbsMinus1 = s->mb_height - 1; pp->wFrameHeightInMbsMinus1 = h->mb_height - 1;
pp->num_ref_frames = h->sps.ref_frame_count; pp->num_ref_frames = h->sps.ref_frame_count;
pp->wBitFields = ((s->picture_structure != PICT_FRAME) << 0) | pp->wBitFields = ((h->picture_structure != PICT_FRAME) << 0) |
((h->sps.mb_aff && ((h->sps.mb_aff &&
(s->picture_structure == PICT_FRAME)) << 1) | (h->picture_structure == PICT_FRAME)) << 1) |
(h->sps.residual_color_transform_flag << 2) | (h->sps.residual_color_transform_flag << 2) |
/* sp_for_switch_flag (not implemented by FFmpeg) */ /* sp_for_switch_flag (not implemented by FFmpeg) */
(0 << 3) | (0 << 3) |
...@@ -120,11 +119,11 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context ...@@ -120,11 +119,11 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */ pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */
pp->StatusReportFeedbackNumber = 1 + ctx->report_id++; pp->StatusReportFeedbackNumber = 1 + ctx->report_id++;
pp->CurrFieldOrderCnt[0] = 0; pp->CurrFieldOrderCnt[0] = 0;
if ((s->picture_structure & PICT_TOP_FIELD) && if ((h->picture_structure & PICT_TOP_FIELD) &&
current_picture->field_poc[0] != INT_MAX) current_picture->field_poc[0] != INT_MAX)
pp->CurrFieldOrderCnt[0] = current_picture->field_poc[0]; pp->CurrFieldOrderCnt[0] = current_picture->field_poc[0];
pp->CurrFieldOrderCnt[1] = 0; pp->CurrFieldOrderCnt[1] = 0;
if ((s->picture_structure & PICT_BOTTOM_FIELD) && if ((h->picture_structure & PICT_BOTTOM_FIELD) &&
current_picture->field_poc[1] != INT_MAX) current_picture->field_poc[1] != INT_MAX)
pp->CurrFieldOrderCnt[1] = current_picture->field_poc[1]; pp->CurrFieldOrderCnt[1] = current_picture->field_poc[1];
pp->pic_init_qs_minus26 = h->pps.init_qs - 26; pp->pic_init_qs_minus26 = h->pps.init_qs - 26;
...@@ -200,7 +199,6 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -200,7 +199,6 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
{ {
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 MpegEncContext *s = &h->s;
unsigned list; unsigned list;
memset(slice, 0, sizeof(*slice)); memset(slice, 0, sizeof(*slice));
...@@ -208,9 +206,9 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -208,9 +206,9 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->SliceBytesInBuffer = size; slice->SliceBytesInBuffer = size;
slice->wBadSliceChopping = 0; slice->wBadSliceChopping = 0;
slice->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x; slice->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE) * h->mb_width + h->mb_x;
slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */ slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */
slice->BitOffsetToSliceData = get_bits_count(&s->gb); slice->BitOffsetToSliceData = get_bits_count(&h->gb);
slice->slice_type = ff_h264_get_slice_type(h); slice->slice_type = ff_h264_get_slice_type(h);
if (h->slice_type_fixed) if (h->slice_type_fixed)
slice->slice_type += 5; slice->slice_type += 5;
...@@ -260,7 +258,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -260,7 +258,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
} }
} }
slice->slice_qs_delta = 0; /* XXX not implemented by FFmpeg */ slice->slice_qs_delta = 0; /* XXX not implemented by FFmpeg */
slice->slice_qp_delta = s->qscale - h->pps.init_qp; slice->slice_qp_delta = h->qscale - h->pps.init_qp;
slice->redundant_pic_cnt = h->redundant_pic_count; slice->redundant_pic_cnt = h->redundant_pic_count;
if (h->slice_type == AV_PICTURE_TYPE_B) if (h->slice_type == AV_PICTURE_TYPE_B)
slice->direct_spatial_mv_pred_flag = h->direct_spatial_mv_pred; slice->direct_spatial_mv_pred_flag = h->direct_spatial_mv_pred;
...@@ -277,10 +275,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, ...@@ -277,10 +275,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
DXVA2_DecodeBufferDesc *sc) DXVA2_DecodeBufferDesc *sc)
{ {
const H264Context *h = avctx->priv_data; const H264Context *h = avctx->priv_data;
const MpegEncContext *s = &h->s; const unsigned mb_count = h->mb_width * h->mb_height;
const unsigned mb_count = s->mb_width * s->mb_height;
struct dxva_context *ctx = avctx->hwaccel_context; struct dxva_context *ctx = avctx->hwaccel_context;
const Picture *current_picture = h->s.current_picture_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->f.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;
...@@ -376,7 +373,7 @@ static int start_frame(AVCodecContext *avctx, ...@@ -376,7 +373,7 @@ static int 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->s.current_picture_ptr->f.hwaccel_picture_private; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->f.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;
...@@ -399,7 +396,7 @@ static int decode_slice(AVCodecContext *avctx, ...@@ -399,7 +396,7 @@ static int 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->s.current_picture_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->f.hwaccel_picture_private;
unsigned position; unsigned position;
...@@ -427,16 +424,19 @@ static int decode_slice(AVCodecContext *avctx, ...@@ -427,16 +424,19 @@ static int decode_slice(AVCodecContext *avctx,
static int end_frame(AVCodecContext *avctx) static int end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
MpegEncContext *s = &h->s;
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
h->s.current_picture_ptr->f.hwaccel_picture_private; h->cur_pic_ptr->f.hwaccel_picture_private;
int ret;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1; return -1;
return ff_dxva2_common_end_frame(avctx, s, ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr,
&ctx_pic->pp, sizeof(ctx_pic->pp), &ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm), &ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer); commit_bitstream_and_slice_buffer);
if (!ret)
ff_h264_draw_horiz_band(h, 0, h->avctx->height);
return ret;
} }
AVHWAccel ff_h264_dxva2_hwaccel = { AVHWAccel ff_h264_dxva2_hwaccel = {
......
...@@ -54,7 +54,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *, struct dxva_context *, ...@@ -54,7 +54,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *, struct dxva_context *,
unsigned mb_count); unsigned mb_count);
int ff_dxva2_common_end_frame(AVCodecContext *, MpegEncContext *, int ff_dxva2_common_end_frame(AVCodecContext *, Picture *,
const void *pp, unsigned pp_size, const void *pp, unsigned pp_size,
const void *qm, unsigned qm_size, const void *qm, unsigned qm_size,
int (*commit_bs_si)(AVCodecContext *, int (*commit_bs_si)(AVCodecContext *,
......
...@@ -251,13 +251,17 @@ static int end_frame(AVCodecContext *avctx) ...@@ -251,13 +251,17 @@ static int 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->f.hwaccel_picture_private;
int ret;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1; return -1;
return ff_dxva2_common_end_frame(avctx, s, ret = ff_dxva2_common_end_frame(avctx, s->current_picture_ptr,
&ctx_pic->pp, sizeof(ctx_pic->pp), &ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm), &ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer); commit_bitstream_and_slice_buffer);
if (!ret)
ff_mpeg_draw_horiz_band(s, 0, avctx->height);
return ret;
} }
AVHWAccel ff_mpeg2_dxva2_hwaccel = { AVHWAccel ff_mpeg2_dxva2_hwaccel = {
......
...@@ -257,14 +257,18 @@ static int end_frame(AVCodecContext *avctx) ...@@ -257,14 +257,18 @@ static int 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->f.hwaccel_picture_private;
int ret;
if (ctx_pic->bitstream_size <= 0) if (ctx_pic->bitstream_size <= 0)
return -1; return -1;
return ff_dxva2_common_end_frame(avctx, &v->s, ret = ff_dxva2_common_end_frame(avctx, v->s.current_picture_ptr,
&ctx_pic->pp, sizeof(ctx_pic->pp), &ctx_pic->pp, sizeof(ctx_pic->pp),
NULL, 0, NULL, 0,
commit_bitstream_and_slice_buffer); commit_bitstream_and_slice_buffer);
if (!ret)
ff_mpeg_draw_horiz_band(&v->s, 0, avctx->height);
return ret;
} }
#if CONFIG_WMV3_DXVA2_HWACCEL #if CONFIG_WMV3_DXVA2_HWACCEL
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "cabac.h" #include "cabac.h"
#include "get_bits.h"
#include "mpegvideo.h" #include "mpegvideo.h"
#include "h264chroma.h" #include "h264chroma.h"
#include "h264dsp.h" #include "h264dsp.h"
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
#define MB_MBAFF h->mb_mbaff #define MB_MBAFF h->mb_mbaff
#define MB_FIELD h->mb_field_decoding_flag #define MB_FIELD h->mb_field_decoding_flag
#define FRAME_MBAFF h->mb_aff_frame #define FRAME_MBAFF h->mb_aff_frame
#define FIELD_PICTURE (s->picture_structure != PICT_FRAME) #define FIELD_PICTURE (h->picture_structure != PICT_FRAME)
#define LEFT_MBS 2 #define LEFT_MBS 2
#define LTOP 0 #define LTOP 0
#define LBOT 1 #define LBOT 1
...@@ -254,15 +255,42 @@ typedef struct MMCO { ...@@ -254,15 +255,42 @@ typedef struct MMCO {
* H264Context * H264Context
*/ */
typedef struct H264Context { typedef struct H264Context {
MpegEncContext s; AVCodecContext *avctx;
DSPContext dsp;
VideoDSPContext vdsp;
H264DSPContext h264dsp; H264DSPContext h264dsp;
H264ChromaContext h264chroma; H264ChromaContext h264chroma;
H264QpelContext h264qpel; H264QpelContext h264qpel;
MotionEstContext me;
ParseContext parse_context;
GetBitContext gb;
ERContext er;
Picture *DPB;
Picture *cur_pic_ptr;
Picture cur_pic;
int picture_count;
int picture_range_start, picture_range_end;
int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264 int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
int chroma_qp[2]; // QPc int chroma_qp[2]; // QPc
int qp_thresh; ///< QP threshold to skip loopfilter int qp_thresh; ///< QP threshold to skip loopfilter
int width, height;
int linesize, uvlinesize;
int chroma_x_shift, chroma_y_shift;
int qscale;
int droppable;
int data_partitioning;
int coded_picture_number;
int low_delay;
int context_initialized;
int flags;
int workaround_bugs;
int prev_mb_skipped; int prev_mb_skipped;
int next_mb_skipped; int next_mb_skipped;
...@@ -352,6 +380,8 @@ typedef struct H264Context { ...@@ -352,6 +380,8 @@ typedef struct H264Context {
int mb_aff_frame; int mb_aff_frame;
int mb_field_decoding_flag; int mb_field_decoding_flag;
int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag
int picture_structure;
int first_field;
DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
...@@ -428,6 +458,13 @@ typedef struct H264Context { ...@@ -428,6 +458,13 @@ typedef struct H264Context {
int x264_build; int x264_build;
int mb_x, mb_y;
int resync_mb_x;
int resync_mb_y;
int mb_skip_run;
int mb_height, mb_width;
int mb_stride;
int mb_num;
int mb_xy; int mb_xy;
int is_complex; int is_complex;
...@@ -452,7 +489,8 @@ typedef struct H264Context { ...@@ -452,7 +489,8 @@ typedef struct H264Context {
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
int got_first; ///< this flag is != 0 if we've parsed a frame int got_first; ///< this flag is != 0 if we've parsed a frame
int context_reinitialized; int bit_depth_luma; ///< luma bit depth from sps to detect changes
int chroma_format_idc; ///< chroma format from sps to detect changes
SPS *sps_buffers[MAX_SPS_COUNT]; SPS *sps_buffers[MAX_SPS_COUNT];
PPS *pps_buffers[MAX_PPS_COUNT]; PPS *pps_buffers[MAX_PPS_COUNT];
...@@ -525,12 +563,16 @@ typedef struct H264Context { ...@@ -525,12 +563,16 @@ typedef struct H264Context {
*/ */
int max_contexts; int max_contexts;
int slice_context_count;
/** /**
* 1 if the single thread fallback warning has already been * 1 if the single thread fallback warning has already been
* displayed, 0 otherwise. * displayed, 0 otherwise.
*/ */
int single_decode_warning; int single_decode_warning;
enum AVPictureType pict_type;
int last_slice_type; int last_slice_type;
/** @} */ /** @} */
...@@ -602,6 +644,8 @@ typedef struct H264Context { ...@@ -602,6 +644,8 @@ typedef struct H264Context {
uint8_t parse_history[4]; uint8_t parse_history[4];
int parse_history_count; int parse_history_count;
int parse_last_mb; int parse_last_mb;
uint8_t *edge_emu_buffer;
int16_t *dc_val_base;
} H264Context; } H264Context;
extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-14). extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-14).
...@@ -810,7 +854,7 @@ static av_always_inline int pred_intra_mode(H264Context *h, int n) ...@@ -810,7 +854,7 @@ static av_always_inline int pred_intra_mode(H264Context *h, int n)
const int top = h->intra4x4_pred_mode_cache[index8 - 8]; const int top = h->intra4x4_pred_mode_cache[index8 - 8];
const int min = FFMIN(left, top); const int min = FFMIN(left, top);
tprintf(h->s.avctx, "mode:%d %d min:%d\n", left, top, min); tprintf(h->avctx, "mode:%d %d min:%d\n", left, top, min);
if (min < 0) if (min < 0)
return DC_PRED; return DC_PRED;
...@@ -844,7 +888,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h) ...@@ -844,7 +888,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h)
AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]);
AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]);
if (!h->s.chroma_y_shift) { if (!h->chroma_y_shift) {
AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]);
AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]);
AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]);
...@@ -853,12 +897,11 @@ static av_always_inline void write_back_non_zero_count(H264Context *h) ...@@ -853,12 +897,11 @@ static av_always_inline void write_back_non_zero_count(H264Context *h)
} }
static av_always_inline void write_back_motion_list(H264Context *h, static av_always_inline void write_back_motion_list(H264Context *h,
MpegEncContext *const s,
int b_stride, int b_stride,
int b_xy, int b8_xy, int b_xy, int b8_xy,
int mb_type, int list) int mb_type, int list)
{ {
int16_t(*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; int16_t(*mv_dst)[2] = &h->cur_pic.f.motion_val[list][b_xy];
int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]]; int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]];
AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0);
AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1);
...@@ -879,7 +922,7 @@ static av_always_inline void write_back_motion_list(H264Context *h, ...@@ -879,7 +922,7 @@ static av_always_inline void write_back_motion_list(H264Context *h,
} }
{ {
int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; int8_t *ref_index = &h->cur_pic.f.ref_index[list][b8_xy];
int8_t *ref_cache = h->ref_cache[list]; int8_t *ref_cache = h->ref_cache[list];
ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; ref_index[0 + 0 * 2] = ref_cache[scan8[0]];
ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; ref_index[1 + 0 * 2] = ref_cache[scan8[4]];
...@@ -890,19 +933,18 @@ static av_always_inline void write_back_motion_list(H264Context *h, ...@@ -890,19 +933,18 @@ static av_always_inline void write_back_motion_list(H264Context *h,
static av_always_inline void write_back_motion(H264Context *h, int mb_type) static av_always_inline void write_back_motion(H264Context *h, int mb_type)
{ {
MpegEncContext *const s = &h->s;
const int b_stride = h->b_stride; const int b_stride = h->b_stride;
const int b_xy = 4 * s->mb_x + 4 * s->mb_y * h->b_stride; // try mb2b(8)_xy const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride; // try mb2b(8)_xy
const int b8_xy = 4 * h->mb_xy; const int b8_xy = 4 * h->mb_xy;
if (USES_LIST(mb_type, 0)) { if (USES_LIST(mb_type, 0)) {
write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); write_back_motion_list(h, b_stride, b_xy, b8_xy, mb_type, 0);
} else { } else {
fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], fill_rectangle(&h->cur_pic.f.ref_index[0][b8_xy],
2, 2, 2, (uint8_t)LIST_NOT_USED, 1); 2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
} }
if (USES_LIST(mb_type, 1)) if (USES_LIST(mb_type, 1))
write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1); write_back_motion_list(h, b_stride, b_xy, b8_xy, mb_type, 1);
if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) { if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) {
if (IS_8X8(mb_type)) { if (IS_8X8(mb_type)) {
...@@ -926,4 +968,6 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h) ...@@ -926,4 +968,6 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h)
0x0001000100010001ULL)); 0x0001000100010001ULL));
} }
void ff_h264_draw_horiz_band(H264Context *h, int y, int height);
#endif /* AVCODEC_H264_H */ #endif /* AVCODEC_H264_H */
This diff is collapsed.
This diff is collapsed.
...@@ -50,14 +50,13 @@ static int get_scale_factor(H264Context * const h, int poc, int poc1, int i){ ...@@ -50,14 +50,13 @@ static int get_scale_factor(H264Context * const h, int poc, int poc1, int i){
} }
void ff_h264_direct_dist_scale_factor(H264Context * const h){ void ff_h264_direct_dist_scale_factor(H264Context * const h){
MpegEncContext * const s = &h->s; const int poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
const int poc = h->s.current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ];
const int poc1 = h->ref_list[1][0].poc; const int poc1 = h->ref_list[1][0].poc;
int i, field; int i, field;
if (FRAME_MBAFF) if (FRAME_MBAFF)
for (field = 0; field < 2; field++){ for (field = 0; field < 2; field++){
const int poc = h->s.current_picture_ptr->field_poc[field]; const int poc = h->cur_pic_ptr->field_poc[field];
const int poc1 = h->ref_list[1][0].field_poc[field]; const int poc1 = h->ref_list[1][0].field_poc[field];
for (i = 0; i < 2 * h->ref_count[0]; i++) for (i = 0; i < 2 * h->ref_count[0]; i++)
h->dist_scale_factor_field[field][i^field] = h->dist_scale_factor_field[field][i^field] =
...@@ -70,12 +69,11 @@ void ff_h264_direct_dist_scale_factor(H264Context * const h){ ...@@ -70,12 +69,11 @@ void ff_h264_direct_dist_scale_factor(H264Context * const h){
} }
static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){
MpegEncContext * const s = &h->s;
Picture * const ref1 = &h->ref_list[1][0]; Picture * const ref1 = &h->ref_list[1][0];
int j, old_ref, rfield; int j, old_ref, rfield;
int start= mbafi ? 16 : 0; int start= mbafi ? 16 : 0;
int end = mbafi ? 16+2*h->ref_count[0] : h->ref_count[0]; int end = mbafi ? 16+2*h->ref_count[0] : h->ref_count[0];
int interl= mbafi || s->picture_structure != PICT_FRAME; int interl= mbafi || h->picture_structure != PICT_FRAME;
/* bogus; fills in for missing frames */ /* bogus; fills in for missing frames */
memset(map[list], 0, sizeof(map[list])); memset(map[list], 0, sizeof(map[list]));
...@@ -104,11 +102,10 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, ...@@ -104,11 +102,10 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field,
} }
void ff_h264_direct_ref_list_init(H264Context * const h){ void ff_h264_direct_ref_list_init(H264Context * const h){
MpegEncContext * const s = &h->s;
Picture * const ref1 = &h->ref_list[1][0]; Picture * const ref1 = &h->ref_list[1][0];
Picture * const cur = s->current_picture_ptr; Picture * const cur = h->cur_pic_ptr;
int list, j, field; int list, j, field;
int sidx= (s->picture_structure&1)^1; int sidx= (h->picture_structure&1)^1;
int ref1sidx = (ref1->f.reference&1)^1; int ref1sidx = (ref1->f.reference&1)^1;
for(list=0; list<2; list++){ for(list=0; list<2; list++){
...@@ -117,7 +114,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ ...@@ -117,7 +114,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){
cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3); cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3);
} }
if(s->picture_structure == PICT_FRAME){ if(h->picture_structure == PICT_FRAME){
memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0])); memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));
memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0])); memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0]));
} }
...@@ -125,12 +122,12 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ ...@@ -125,12 +122,12 @@ void ff_h264_direct_ref_list_init(H264Context * const h){
cur->mbaff= FRAME_MBAFF; cur->mbaff= FRAME_MBAFF;
h->col_fieldoff= 0; h->col_fieldoff= 0;
if(s->picture_structure == PICT_FRAME){ if(h->picture_structure == PICT_FRAME){
int cur_poc = s->current_picture_ptr->poc; int cur_poc = h->cur_pic_ptr->poc;
int *col_poc = h->ref_list[1]->field_poc; int *col_poc = h->ref_list[1]->field_poc;
h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc)); h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc));
ref1sidx=sidx= h->col_parity; ref1sidx=sidx= h->col_parity;
} else if (!(s->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { // FL -> FL & differ parity } else if (!(h->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { // FL -> FL & differ parity
h->col_fieldoff = 2 * h->ref_list[1][0].f.reference - 3; h->col_fieldoff = 2 * h->ref_list[1][0].f.reference - 3;
} }
...@@ -149,9 +146,9 @@ static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y ...@@ -149,9 +146,9 @@ static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y
{ {
int ref_field = ref->f.reference - 1; int ref_field = ref->f.reference - 1;
int ref_field_picture = ref->field_picture; int ref_field_picture = ref->field_picture;
int ref_height = 16*h->s.mb_height >> ref_field_picture; int ref_height = 16*h->mb_height >> ref_field_picture;
if(!HAVE_THREADS || !(h->s.avctx->active_thread_type&FF_THREAD_FRAME)) if(!HAVE_THREADS || !(h->avctx->active_thread_type&FF_THREAD_FRAME))
return; return;
//FIXME it can be safe to access mb stuff //FIXME it can be safe to access mb stuff
...@@ -163,10 +160,9 @@ static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y ...@@ -163,10 +160,9 @@ static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y
} }
static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
MpegEncContext * const s = &h->s;
int b8_stride = 2; int b8_stride = 2;
int b4_stride = h->b_stride; int b4_stride = h->b_stride;
int mb_xy = h->mb_xy, mb_y = s->mb_y; int mb_xy = h->mb_xy, mb_y = h->mb_y;
int mb_type_col[2]; int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1; const int8_t *l1ref0, *l1ref1;
...@@ -179,7 +175,7 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ ...@@ -179,7 +175,7 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
assert(h->ref_list[1][0].f.reference & 3); assert(h->ref_list[1][0].f.reference & 3);
await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type)); await_reference_mb_row(h, &h->ref_list[1][0], h->mb_y + !!IS_INTERLACED(*mb_type));
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM) #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
...@@ -241,21 +237,21 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ ...@@ -241,21 +237,21 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (s->mb_y&~1) + h->col_parity; mb_y = (h->mb_y&~1) + h->col_parity;
mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; mb_xy= h->mb_x + ((h->mb_y&~1) + h->col_parity)*h->mb_stride;
b8_stride = 0; b8_stride = 0;
}else{ }else{
mb_y += h->col_fieldoff; mb_y += h->col_fieldoff;
mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity mb_xy += h->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity
} }
goto single_col; goto single_col;
}else{ // AFL/AFR/FR/FL -> AFR/FR }else{ // AFL/AFR/FR/FL -> AFR/FR
if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR
mb_y = s->mb_y&~1; mb_y = h->mb_y&~1;
mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_xy= h->mb_x + (h->mb_y&~1)*h->mb_stride;
mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy]; mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride]; mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + h->mb_stride];
b8_stride = 2+4*s->mb_stride; b8_stride = 2+4*h->mb_stride;
b4_stride *= 6; b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) { if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED; mb_type_col[0] &= ~MB_TYPE_INTERLACED;
...@@ -298,7 +294,7 @@ single_col: ...@@ -298,7 +294,7 @@ single_col:
l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy]; l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy]; l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
if(!b8_stride){ if(!b8_stride){
if(s->mb_y&1){ if(h->mb_y&1){
l1ref0 += 2; l1ref0 += 2;
l1ref1 += 2; l1ref1 += 2;
l1mv0 += 2*b4_stride; l1mv0 += 2*b4_stride;
...@@ -414,10 +410,9 @@ single_col: ...@@ -414,10 +410,9 @@ single_col:
} }
static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
MpegEncContext * const s = &h->s;
int b8_stride = 2; int b8_stride = 2;
int b4_stride = h->b_stride; int b4_stride = h->b_stride;
int mb_xy = h->mb_xy, mb_y = s->mb_y; int mb_xy = h->mb_xy, mb_y = h->mb_y;
int mb_type_col[2]; int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1; const int8_t *l1ref0, *l1ref1;
...@@ -427,25 +422,25 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ ...@@ -427,25 +422,25 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
assert(h->ref_list[1][0].f.reference & 3); assert(h->ref_list[1][0].f.reference & 3);
await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type)); await_reference_mb_row(h, &h->ref_list[1][0], h->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (s->mb_y&~1) + h->col_parity; mb_y = (h->mb_y&~1) + h->col_parity;
mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; mb_xy= h->mb_x + ((h->mb_y&~1) + h->col_parity)*h->mb_stride;
b8_stride = 0; b8_stride = 0;
}else{ }else{
mb_y += h->col_fieldoff; mb_y += h->col_fieldoff;
mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity mb_xy += h->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity
} }
goto single_col; goto single_col;
}else{ // AFL/AFR/FR/FL -> AFR/FR }else{ // AFL/AFR/FR/FL -> AFR/FR
if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR
mb_y = s->mb_y&~1; mb_y = h->mb_y&~1;
mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_xy= h->mb_x + (h->mb_y&~1)*h->mb_stride;
mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy]; mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride]; mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + h->mb_stride];
b8_stride = 2+4*s->mb_stride; b8_stride = 2+4*h->mb_stride;
b4_stride *= 6; b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) { if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED; mb_type_col[0] &= ~MB_TYPE_INTERLACED;
...@@ -489,7 +484,7 @@ single_col: ...@@ -489,7 +484,7 @@ single_col:
l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy]; l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy]; l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
if(!b8_stride){ if(!b8_stride){
if(s->mb_y&1){ if(h->mb_y&1){
l1ref0 += 2; l1ref0 += 2;
l1ref1 += 2; l1ref1 += 2;
l1mv0 += 2*b4_stride; l1mv0 += 2*b4_stride;
...@@ -503,9 +498,9 @@ single_col: ...@@ -503,9 +498,9 @@ single_col:
int ref_offset; int ref_offset;
if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){ if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){
map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0]; map_col_to_list0[0] = h->map_col_to_list0_field[h->mb_y&1][0];
map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1]; map_col_to_list0[1] = h->map_col_to_list0_field[h->mb_y&1][1];
dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1]; dist_scale_factor =h->dist_scale_factor_field[h->mb_y&1];
} }
ref_offset = (h->ref_list[1][0].mbaff<<4) & (mb_type_col[0]>>3); //if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) ref_offset=16 else 0 ref_offset = (h->ref_list[1][0].mbaff<<4) & (mb_type_col[0]>>3); //if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) ref_offset=16 else 0
......
This diff is collapsed.
This diff is collapsed.
...@@ -46,7 +46,7 @@ static void mc_part(H264Context *h, int n, int square, ...@@ -46,7 +46,7 @@ static void mc_part(H264Context *h, int n, int square,
int list0, int list1) int list0, int list1)
{ {
if ((h->use_weight == 2 && list0 && list1 && if ((h->use_weight == 2 && list0 && list1 &&
(h->implicit_weight[h->ref_cache[0][scan8[n]]][h->ref_cache[1][scan8[n]]][h->s.mb_y & 1] != 32)) || (h->implicit_weight[h->ref_cache[0][scan8[n]]][h->ref_cache[1][scan8[n]]][h->mb_y & 1] != 32)) ||
h->use_weight == 1) h->use_weight == 1)
mc_part_weighted(h, n, square, height, delta, dest_y, dest_cb, dest_cr, mc_part_weighted(h, n, square, height, delta, dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put, x_offset, y_offset, qpix_put, chroma_put,
...@@ -67,13 +67,12 @@ static void MCFUNC(hl_motion)(H264Context *h, uint8_t *dest_y, ...@@ -67,13 +67,12 @@ static void MCFUNC(hl_motion)(H264Context *h, uint8_t *dest_y,
h264_weight_func *weight_op, h264_weight_func *weight_op,
h264_biweight_func *weight_avg) h264_biweight_func *weight_avg)
{ {
MpegEncContext *const s = &h->s;
const int mb_xy = h->mb_xy; const int mb_xy = h->mb_xy;
const int mb_type = s->current_picture.f.mb_type[mb_xy]; const int mb_type = h->cur_pic.f.mb_type[mb_xy];
av_assert2(IS_INTER(mb_type)); av_assert2(IS_INTER(mb_type));
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) if (HAVE_THREADS && (h->avctx->active_thread_type & FF_THREAD_FRAME))
await_references(h); await_references(h);
prefetch_motion(h, 0, PIXEL_SHIFT, CHROMA_IDC); prefetch_motion(h, 0, PIXEL_SHIFT, CHROMA_IDC);
......
This diff is collapsed.
...@@ -36,7 +36,7 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si ...@@ -36,7 +36,7 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si
{ {
int i, j; int i, j;
uint32_t state; uint32_t state;
ParseContext *pc = &(h->s.parse_context); ParseContext *pc = &h->parse_context;
int next_avc= h->is_avc ? 0 : buf_size; int next_avc= h->is_avc ? 0 : buf_size;
// mb_addr= pc->mb_addr - 1; // mb_addr= pc->mb_addr - 1;
...@@ -45,7 +45,7 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si ...@@ -45,7 +45,7 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si
state= 7; state= 7;
if(h->is_avc && !h->nal_length_size) if(h->is_avc && !h->nal_length_size)
av_log(h->s.avctx, AV_LOG_ERROR, "AVC-parser: nal length size invalid\n"); av_log(h->avctx, AV_LOG_ERROR, "AVC-parser: nal length size invalid\n");
for(i=0; i<buf_size; i++){ for(i=0; i<buf_size; i++){
if(i >= next_avc) { if(i >= next_avc) {
...@@ -54,7 +54,7 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si ...@@ -54,7 +54,7 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si
for(j = 0; j < h->nal_length_size; j++) for(j = 0; j < h->nal_length_size; j++)
nalsize = (nalsize << 8) | buf[i++]; nalsize = (nalsize << 8) | buf[i++];
if(nalsize <= 0 || nalsize > buf_size - i){ if(nalsize <= 0 || nalsize > buf_size - i){
av_log(h->s.avctx, AV_LOG_ERROR, "AVC-parser: nal size %d remaining %d\n", nalsize, buf_size - i); av_log(h->avctx, AV_LOG_ERROR, "AVC-parser: nal size %d remaining %d\n", nalsize, buf_size - i);
return buf_size; return buf_size;
} }
next_avc= i + nalsize; next_avc= i + nalsize;
...@@ -153,7 +153,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -153,7 +153,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
s->pict_type = AV_PICTURE_TYPE_I; s->pict_type = AV_PICTURE_TYPE_I;
s->key_frame = 0; s->key_frame = 0;
h->s.avctx= avctx; h->avctx= avctx;
h->sei_recovery_frame_cnt = -1; h->sei_recovery_frame_cnt = -1;
h->sei_dpb_output_delay = 0; h->sei_dpb_output_delay = 0;
h->sei_cpb_removal_delay = -1; h->sei_cpb_removal_delay = -1;
...@@ -171,7 +171,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -171,7 +171,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
for (i = 0; i < h->nal_length_size; i++) for (i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | *buf++; nalsize = (nalsize << 8) | *buf++;
if (nalsize <= 0 || nalsize > buf_end - buf) { if (nalsize <= 0 || nalsize > buf_end - buf) {
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize); av_log(h->avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
break; break;
} }
src_length = nalsize; src_length = nalsize;
...@@ -194,13 +194,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -194,13 +194,13 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (ptr==NULL || dst_length < 0) if (ptr==NULL || dst_length < 0)
break; break;
init_get_bits(&h->s.gb, ptr, 8*dst_length); init_get_bits(&h->gb, ptr, 8*dst_length);
switch(h->nal_unit_type) { switch(h->nal_unit_type) {
case NAL_SPS: case NAL_SPS:
ff_h264_decode_seq_parameter_set(h); ff_h264_decode_seq_parameter_set(h);
break; break;
case NAL_PPS: case NAL_PPS:
ff_h264_decode_picture_parameter_set(h, h->s.gb.size_in_bits); ff_h264_decode_picture_parameter_set(h, h->gb.size_in_bits);
break; break;
case NAL_SEI: case NAL_SEI:
ff_h264_decode_sei(h); ff_h264_decode_sei(h);
...@@ -209,40 +209,40 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -209,40 +209,40 @@ static inline int parse_nal_units(AVCodecParserContext *s,
s->key_frame = 1; s->key_frame = 1;
/* fall through */ /* fall through */
case NAL_SLICE: case NAL_SLICE:
get_ue_golomb_long(&h->s.gb); // skip first_mb_in_slice get_ue_golomb_long(&h->gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&h->s.gb); slice_type = get_ue_golomb_31(&h->gb);
s->pict_type = golomb_to_pict_type[slice_type % 5]; s->pict_type = golomb_to_pict_type[slice_type % 5];
if (h->sei_recovery_frame_cnt >= 0) { if (h->sei_recovery_frame_cnt >= 0) {
/* key frame, since recovery_frame_cnt is set */ /* key frame, since recovery_frame_cnt is set */
s->key_frame = 1; s->key_frame = 1;
} }
pps_id= get_ue_golomb(&h->s.gb); pps_id= get_ue_golomb(&h->gb);
if(pps_id>=MAX_PPS_COUNT) { if(pps_id>=MAX_PPS_COUNT) {
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n"); av_log(h->avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1; return -1;
} }
if(!h->pps_buffers[pps_id]) { if(!h->pps_buffers[pps_id]) {
av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS referenced\n"); av_log(h->avctx, AV_LOG_ERROR, "non-existing PPS referenced\n");
return -1; return -1;
} }
h->pps= *h->pps_buffers[pps_id]; h->pps= *h->pps_buffers[pps_id];
if(!h->sps_buffers[h->pps.sps_id]) { if(!h->sps_buffers[h->pps.sps_id]) {
av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS referenced\n"); av_log(h->avctx, AV_LOG_ERROR, "non-existing SPS referenced\n");
return -1; return -1;
} }
h->sps = *h->sps_buffers[h->pps.sps_id]; h->sps = *h->sps_buffers[h->pps.sps_id];
h->frame_num = get_bits(&h->s.gb, h->sps.log2_max_frame_num); h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
avctx->profile = ff_h264_get_profile(&h->sps); avctx->profile = ff_h264_get_profile(&h->sps);
avctx->level = h->sps.level_idc; avctx->level = h->sps.level_idc;
if(h->sps.frame_mbs_only_flag){ if(h->sps.frame_mbs_only_flag){
h->s.picture_structure= PICT_FRAME; h->picture_structure= PICT_FRAME;
}else{ }else{
if(get_bits1(&h->s.gb)) { //field_pic_flag if(get_bits1(&h->gb)) { //field_pic_flag
h->s.picture_structure= PICT_TOP_FIELD + get_bits1(&h->s.gb); //bottom_field_flag h->picture_structure= PICT_TOP_FIELD + get_bits1(&h->gb); //bottom_field_flag
} else { } else {
h->s.picture_structure= PICT_FRAME; h->picture_structure= PICT_FRAME;
} }
} }
...@@ -268,11 +268,11 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -268,11 +268,11 @@ static inline int parse_nal_units(AVCodecParserContext *s,
s->repeat_pict = 5; s->repeat_pict = 5;
break; break;
default: default:
s->repeat_pict = h->s.picture_structure == PICT_FRAME ? 1 : 0; s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
break; break;
} }
} else { } else {
s->repeat_pict = h->s.picture_structure == PICT_FRAME ? 1 : 0; s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
} }
return 0; /* no need to evaluate the rest */ return 0; /* no need to evaluate the rest */
...@@ -282,7 +282,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -282,7 +282,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (q264) if (q264)
return 0; return 0;
/* didn't find a picture! */ /* didn't find a picture! */
av_log(h->s.avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size); av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size);
return -1; return -1;
} }
...@@ -292,19 +292,19 @@ static int h264_parse(AVCodecParserContext *s, ...@@ -292,19 +292,19 @@ static int h264_parse(AVCodecParserContext *s,
const uint8_t *buf, int buf_size) const uint8_t *buf, int buf_size)
{ {
H264Context *h = s->priv_data; H264Context *h = s->priv_data;
ParseContext *pc = &h->s.parse_context; ParseContext *pc = &h->parse_context;
int next; int next;
if (!h->got_first) { if (!h->got_first) {
h->got_first = 1; h->got_first = 1;
if (avctx->extradata_size) { if (avctx->extradata_size) {
h->s.avctx = avctx; h->avctx = avctx;
// must be done like in decoder, otherwise opening the parser, // must be done like in decoder, otherwise opening the parser,
// letting it create extradata and then closing and opening again // letting it create extradata and then closing and opening again
// will cause has_b_frames to be always set. // will cause has_b_frames to be always set.
// Note that estimate_timings_from_pts does exactly this. // Note that estimate_timings_from_pts does exactly this.
if (!avctx->has_b_frames) if (!avctx->has_b_frames)
h->s.low_delay = 1; h->low_delay = 1;
ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size); ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
} }
} }
...@@ -374,7 +374,7 @@ static int h264_split(AVCodecContext *avctx, ...@@ -374,7 +374,7 @@ static int h264_split(AVCodecContext *avctx,
static void close(AVCodecParserContext *s) static void close(AVCodecParserContext *s)
{ {
H264Context *h = s->priv_data; H264Context *h = s->priv_data;
ParseContext *pc = &h->s.parse_context; ParseContext *pc = &h->parse_context;
av_free(pc->buffer); av_free(pc->buffer);
ff_h264_free_context(h); ff_h264_free_context(h);
...@@ -384,7 +384,7 @@ static int init(AVCodecParserContext *s) ...@@ -384,7 +384,7 @@ static int init(AVCodecParserContext *s)
{ {
H264Context *h = s->priv_data; H264Context *h = s->priv_data;
h->thread_context[0] = h; h->thread_context[0] = h;
h->s.slice_context_count = 1; h->slice_context_count = 1;
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -410,8 +410,6 @@ static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride) ...@@ -410,8 +410,6 @@ static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
int chroma_format_idc) int chroma_format_idc)
{ {
// MpegEncContext * const s = &h->s;
#undef FUNC #undef FUNC
#undef FUNCC #undef FUNCC
#define FUNC(a, depth) a ## _ ## depth #define FUNC(a, depth) a ## _ ## depth
......
...@@ -143,7 +143,7 @@ typedef struct Picture{ ...@@ -143,7 +143,7 @@ typedef struct Picture{
uint16_t *mc_mb_var; ///< Table for motion compensated MB variances uint16_t *mc_mb_var; ///< Table for motion compensated MB variances
uint8_t *mb_mean; ///< Table for MB luminance uint8_t *mb_mean; ///< Table for MB luminance
int b_frame_score; /* */ int b_frame_score; /* */
struct MpegEncContext *owner2; ///< pointer to the MpegEncContext 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
} Picture; } Picture;
......
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "h264.h"
#include "vaapi_internal.h" #include "vaapi_internal.h"
/** /**
...@@ -40,7 +41,7 @@ static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int ...@@ -40,7 +41,7 @@ static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int
} }
} }
static int render_picture(struct vaapi_context *vactx, VASurfaceID surface) int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface)
{ {
VABufferID va_buffers[3]; VABufferID va_buffers[3];
unsigned int n_va_buffers = 0; unsigned int n_va_buffers = 0;
...@@ -77,7 +78,7 @@ static int render_picture(struct vaapi_context *vactx, VASurfaceID surface) ...@@ -77,7 +78,7 @@ static int render_picture(struct vaapi_context *vactx, VASurfaceID surface)
return 0; return 0;
} }
static int commit_slices(struct vaapi_context *vactx) int ff_vaapi_commit_slices(struct vaapi_context *vactx)
{ {
VABufferID *slice_buf_ids; VABufferID *slice_buf_ids;
VABufferID slice_param_buf_id, slice_data_buf_id; VABufferID slice_param_buf_id, slice_data_buf_id;
...@@ -152,7 +153,7 @@ VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, co ...@@ -152,7 +153,7 @@ VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, co
if (!vactx->slice_data) if (!vactx->slice_data)
vactx->slice_data = buffer; vactx->slice_data = buffer;
if (vactx->slice_data + vactx->slice_data_size != buffer) { if (vactx->slice_data + vactx->slice_data_size != buffer) {
if (commit_slices(vactx) < 0) if (ff_vaapi_commit_slices(vactx) < 0)
return NULL; return NULL;
vactx->slice_data = buffer; vactx->slice_data = buffer;
} }
...@@ -175,23 +176,12 @@ VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, co ...@@ -175,23 +176,12 @@ VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, co
return slice_param; return slice_param;
} }
int ff_vaapi_common_end_frame(MpegEncContext *s) void ff_vaapi_common_end_frame(AVCodecContext *avctx)
{ {
struct vaapi_context * const vactx = s->avctx->hwaccel_context; struct vaapi_context * const vactx = avctx->hwaccel_context;
int ret = -1;
av_dlog(s->avctx, "ff_vaapi_common_end_frame()\n"); av_dlog(avctx, "ff_vaapi_common_end_frame()\n");
if (commit_slices(vactx) < 0)
goto done;
if (vactx->n_slice_buf_ids > 0) {
if (render_picture(vactx, ff_vaapi_get_surface_id(s->current_picture_ptr)) < 0)
goto done;
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
}
ret = 0;
done:
destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1); destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1);
destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1); destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1);
destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1); destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1);
...@@ -202,6 +192,27 @@ done: ...@@ -202,6 +192,27 @@ done:
vactx->slice_buf_ids_alloc = 0; vactx->slice_buf_ids_alloc = 0;
vactx->slice_count = 0; vactx->slice_count = 0;
vactx->slice_params_alloc = 0; vactx->slice_params_alloc = 0;
}
int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)
{
struct vaapi_context * const vactx = avctx->hwaccel_context;
MpegEncContext *s = avctx->priv_data;
int ret;
ret = ff_vaapi_commit_slices(vactx);
if (ret < 0)
goto finish;
ret = ff_vaapi_render_picture(vactx,
ff_vaapi_get_surface_id(s->current_picture_ptr));
if (ret < 0)
goto finish;
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
finish:
ff_vaapi_common_end_frame(avctx->priv_data);
return ret; return ret;
} }
......
...@@ -224,7 +224,6 @@ static int start_frame(AVCodecContext *avctx, ...@@ -224,7 +224,6 @@ static int start_frame(AVCodecContext *avctx,
av_unused uint32_t size) av_unused uint32_t size)
{ {
H264Context * const h = avctx->priv_data; H264Context * const h = avctx->priv_data;
MpegEncContext * const s = &h->s;
struct vaapi_context * const vactx = avctx->hwaccel_context; struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferH264 *pic_param; VAPictureParameterBufferH264 *pic_param;
VAIQMatrixBufferH264 *iq_matrix; VAIQMatrixBufferH264 *iq_matrix;
...@@ -237,11 +236,11 @@ static int start_frame(AVCodecContext *avctx, ...@@ -237,11 +236,11 @@ static int start_frame(AVCodecContext *avctx,
pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferH264)); pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferH264));
if (!pic_param) if (!pic_param)
return -1; return -1;
fill_vaapi_pic(&pic_param->CurrPic, s->current_picture_ptr, s->picture_structure); fill_vaapi_pic(&pic_param->CurrPic, h->cur_pic_ptr, h->picture_structure);
if (fill_vaapi_ReferenceFrames(pic_param, h) < 0) if (fill_vaapi_ReferenceFrames(pic_param, h) < 0)
return -1; return -1;
pic_param->picture_width_in_mbs_minus1 = s->mb_width - 1; pic_param->picture_width_in_mbs_minus1 = h->mb_width - 1;
pic_param->picture_height_in_mbs_minus1 = s->mb_height - 1; pic_param->picture_height_in_mbs_minus1 = h->mb_height - 1;
pic_param->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; pic_param->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8;
pic_param->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; pic_param->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8;
pic_param->num_ref_frames = h->sps.ref_frame_count; pic_param->num_ref_frames = h->sps.ref_frame_count;
...@@ -269,7 +268,7 @@ static int start_frame(AVCodecContext *avctx, ...@@ -269,7 +268,7 @@ static int start_frame(AVCodecContext *avctx,
pic_param->pic_fields.bits.weighted_pred_flag = h->pps.weighted_pred; pic_param->pic_fields.bits.weighted_pred_flag = h->pps.weighted_pred;
pic_param->pic_fields.bits.weighted_bipred_idc = h->pps.weighted_bipred_idc; pic_param->pic_fields.bits.weighted_bipred_idc = h->pps.weighted_bipred_idc;
pic_param->pic_fields.bits.transform_8x8_mode_flag = h->pps.transform_8x8_mode; pic_param->pic_fields.bits.transform_8x8_mode_flag = h->pps.transform_8x8_mode;
pic_param->pic_fields.bits.field_pic_flag = s->picture_structure != PICT_FRAME; pic_param->pic_fields.bits.field_pic_flag = h->picture_structure != PICT_FRAME;
pic_param->pic_fields.bits.constrained_intra_pred_flag = h->pps.constrained_intra_pred; pic_param->pic_fields.bits.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
pic_param->pic_fields.bits.pic_order_present_flag = h->pps.pic_order_present; pic_param->pic_fields.bits.pic_order_present_flag = h->pps.pic_order_present;
pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
...@@ -290,10 +289,24 @@ static int start_frame(AVCodecContext *avctx, ...@@ -290,10 +289,24 @@ static int start_frame(AVCodecContext *avctx,
/** End a hardware decoding based frame. */ /** End a hardware decoding based frame. */
static int end_frame(AVCodecContext *avctx) static int end_frame(AVCodecContext *avctx)
{ {
struct vaapi_context * const vactx = avctx->hwaccel_context;
H264Context * const h = avctx->priv_data; H264Context * const h = avctx->priv_data;
int ret;
av_dlog(avctx, "end_frame()\n"); av_dlog(avctx, "end_frame()\n");
return ff_vaapi_common_end_frame(&h->s); ret = ff_vaapi_commit_slices(vactx);
if (ret < 0)
goto finish;
ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(h->cur_pic_ptr));
if (ret < 0)
goto finish;
ff_h264_draw_horiz_band(h, 0, h->avctx->height);
finish:
ff_vaapi_common_end_frame(avctx);
return ret;
} }
/** Decode the given H.264 slice with VA API. */ /** Decode the given H.264 slice with VA API. */
...@@ -302,7 +315,6 @@ static int decode_slice(AVCodecContext *avctx, ...@@ -302,7 +315,6 @@ static int decode_slice(AVCodecContext *avctx,
uint32_t size) uint32_t size)
{ {
H264Context * const h = avctx->priv_data; H264Context * const h = avctx->priv_data;
MpegEncContext * const s = &h->s;
VASliceParameterBufferH264 *slice_param; VASliceParameterBufferH264 *slice_param;
av_dlog(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size); av_dlog(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size);
...@@ -311,14 +323,14 @@ static int decode_slice(AVCodecContext *avctx, ...@@ -311,14 +323,14 @@ static int decode_slice(AVCodecContext *avctx,
slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size); slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
if (!slice_param) if (!slice_param)
return -1; return -1;
slice_param->slice_data_bit_offset = get_bits_count(&h->s.gb) + 8; /* bit buffer started beyond nal_unit_type */ slice_param->slice_data_bit_offset = get_bits_count(&h->gb) + 8; /* bit buffer started beyond nal_unit_type */
slice_param->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x; slice_param->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE) * h->mb_width + h->mb_x;
slice_param->slice_type = ff_h264_get_slice_type(h); slice_param->slice_type = ff_h264_get_slice_type(h);
slice_param->direct_spatial_mv_pred_flag = h->slice_type == AV_PICTURE_TYPE_B ? h->direct_spatial_mv_pred : 0; slice_param->direct_spatial_mv_pred_flag = h->slice_type == AV_PICTURE_TYPE_B ? h->direct_spatial_mv_pred : 0;
slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0;
slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0; slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc; slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = s->qscale - h->pps.init_qp; slice_param->slice_qp_delta = h->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter; slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2 - 26; slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2 - 26;
slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2 - 26; slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2 - 26;
......
...@@ -42,7 +42,7 @@ static inline VASurfaceID ff_vaapi_get_surface_id(Picture *pic) ...@@ -42,7 +42,7 @@ static inline VASurfaceID ff_vaapi_get_surface_id(Picture *pic)
} }
/** Common AVHWAccel.end_frame() implementation */ /** Common AVHWAccel.end_frame() implementation */
int ff_vaapi_common_end_frame(MpegEncContext *s); void ff_vaapi_common_end_frame(AVCodecContext *avctx);
/** Allocate a new picture parameter buffer */ /** Allocate a new picture parameter buffer */
void *ff_vaapi_alloc_pic_param(struct vaapi_context *vactx, unsigned int size); void *ff_vaapi_alloc_pic_param(struct vaapi_context *vactx, unsigned int size);
...@@ -63,6 +63,10 @@ uint8_t *ff_vaapi_alloc_bitplane(struct vaapi_context *vactx, uint32_t size); ...@@ -63,6 +63,10 @@ uint8_t *ff_vaapi_alloc_bitplane(struct vaapi_context *vactx, uint32_t size);
*/ */
VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, const uint8_t *buffer, uint32_t size); VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, const uint8_t *buffer, uint32_t size);
int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx);
int ff_vaapi_commit_slices(struct vaapi_context *vactx);
int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface);
/* @} */ /* @} */
#endif /* AVCODEC_VAAPI_INTERNAL_H */ #endif /* AVCODEC_VAAPI_INTERNAL_H */
...@@ -99,11 +99,6 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_ ...@@ -99,11 +99,6 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_
return 0; return 0;
} }
static int vaapi_mpeg2_end_frame(AVCodecContext *avctx)
{
return ff_vaapi_common_end_frame(avctx->priv_data);
}
static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
{ {
MpegEncContext * const s = avctx->priv_data; MpegEncContext * const s = avctx->priv_data;
...@@ -144,6 +139,6 @@ AVHWAccel ff_mpeg2_vaapi_hwaccel = { ...@@ -144,6 +139,6 @@ AVHWAccel ff_mpeg2_vaapi_hwaccel = {
.id = AV_CODEC_ID_MPEG2VIDEO, .id = AV_CODEC_ID_MPEG2VIDEO,
.pix_fmt = AV_PIX_FMT_VAAPI_VLD, .pix_fmt = AV_PIX_FMT_VAAPI_VLD,
.start_frame = vaapi_mpeg2_start_frame, .start_frame = vaapi_mpeg2_start_frame,
.end_frame = vaapi_mpeg2_end_frame, .end_frame = ff_vaapi_mpeg_end_frame,
.decode_slice = vaapi_mpeg2_decode_slice, .decode_slice = vaapi_mpeg2_decode_slice,
}; };
...@@ -115,11 +115,6 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ ...@@ -115,11 +115,6 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
return 0; return 0;
} }
static int vaapi_mpeg4_end_frame(AVCodecContext *avctx)
{
return ff_vaapi_common_end_frame(avctx->priv_data);
}
static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
{ {
MpegEncContext * const s = avctx->priv_data; MpegEncContext * const s = avctx->priv_data;
...@@ -156,7 +151,7 @@ AVHWAccel ff_mpeg4_vaapi_hwaccel = { ...@@ -156,7 +151,7 @@ AVHWAccel ff_mpeg4_vaapi_hwaccel = {
.id = AV_CODEC_ID_MPEG4, .id = AV_CODEC_ID_MPEG4,
.pix_fmt = AV_PIX_FMT_VAAPI_VLD, .pix_fmt = AV_PIX_FMT_VAAPI_VLD,
.start_frame = vaapi_mpeg4_start_frame, .start_frame = vaapi_mpeg4_start_frame,
.end_frame = vaapi_mpeg4_end_frame, .end_frame = ff_vaapi_mpeg_end_frame,
.decode_slice = vaapi_mpeg4_decode_slice, .decode_slice = vaapi_mpeg4_decode_slice,
}; };
#endif #endif
...@@ -168,7 +163,7 @@ AVHWAccel ff_h263_vaapi_hwaccel = { ...@@ -168,7 +163,7 @@ AVHWAccel ff_h263_vaapi_hwaccel = {
.id = AV_CODEC_ID_H263, .id = AV_CODEC_ID_H263,
.pix_fmt = AV_PIX_FMT_VAAPI_VLD, .pix_fmt = AV_PIX_FMT_VAAPI_VLD,
.start_frame = vaapi_mpeg4_start_frame, .start_frame = vaapi_mpeg4_start_frame,
.end_frame = vaapi_mpeg4_end_frame, .end_frame = ff_vaapi_mpeg_end_frame,
.decode_slice = vaapi_mpeg4_decode_slice, .decode_slice = vaapi_mpeg4_decode_slice,
}; };
#endif #endif
...@@ -310,13 +310,6 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t ...@@ -310,13 +310,6 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t
return 0; return 0;
} }
static int vaapi_vc1_end_frame(AVCodecContext *avctx)
{
VC1Context * const v = avctx->priv_data;
return ff_vaapi_common_end_frame(&v->s);
}
static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
{ {
VC1Context * const v = avctx->priv_data; VC1Context * const v = avctx->priv_data;
...@@ -347,7 +340,7 @@ AVHWAccel ff_wmv3_vaapi_hwaccel = { ...@@ -347,7 +340,7 @@ AVHWAccel ff_wmv3_vaapi_hwaccel = {
.id = AV_CODEC_ID_WMV3, .id = AV_CODEC_ID_WMV3,
.pix_fmt = AV_PIX_FMT_VAAPI_VLD, .pix_fmt = AV_PIX_FMT_VAAPI_VLD,
.start_frame = vaapi_vc1_start_frame, .start_frame = vaapi_vc1_start_frame,
.end_frame = vaapi_vc1_end_frame, .end_frame = ff_vaapi_mpeg_end_frame,
.decode_slice = vaapi_vc1_decode_slice, .decode_slice = vaapi_vc1_decode_slice,
}; };
#endif #endif
...@@ -358,6 +351,6 @@ AVHWAccel ff_vc1_vaapi_hwaccel = { ...@@ -358,6 +351,6 @@ AVHWAccel ff_vc1_vaapi_hwaccel = {
.id = AV_CODEC_ID_VC1, .id = AV_CODEC_ID_VC1,
.pix_fmt = AV_PIX_FMT_VAAPI_VLD, .pix_fmt = AV_PIX_FMT_VAAPI_VLD,
.start_frame = vaapi_vc1_start_frame, .start_frame = vaapi_vc1_start_frame,
.end_frame = vaapi_vc1_end_frame, .end_frame = ff_vaapi_mpeg_end_frame,
.decode_slice = vaapi_vc1_decode_slice, .decode_slice = vaapi_vc1_decode_slice,
}; };
...@@ -243,7 +243,7 @@ static int end_frame(AVCodecContext *avctx) ...@@ -243,7 +243,7 @@ static int end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context; struct vda_context *vda_ctx = avctx->hwaccel_context;
AVFrame *frame = &h->s.current_picture_ptr->f; AVFrame *frame = &h->cur_pic_ptr->f;
int status; int status;
if (!vda_ctx->decoder || !vda_ctx->priv_bitstream) if (!vda_ctx->decoder || !vda_ctx->priv_bitstream)
......
...@@ -48,12 +48,10 @@ int ff_vdpau_common_start_frame(AVCodecContext *avctx, ...@@ -48,12 +48,10 @@ int ff_vdpau_common_start_frame(AVCodecContext *avctx,
return 0; return 0;
} }
int ff_vdpau_common_end_frame(AVCodecContext *avctx) int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
{ {
MpegEncContext * const s = avctx->priv_data;
AVVDPAUContext *hwctx = avctx->hwaccel_context; AVVDPAUContext *hwctx = avctx->hwaccel_context;
MpegEncContext *s = avctx->priv_data;
if (hwctx->bitstream_buffers_used) {
VdpVideoSurface surf = ff_vdpau_get_surface_id(s->current_picture_ptr); VdpVideoSurface surf = ff_vdpau_get_surface_id(s->current_picture_ptr);
hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info, hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
...@@ -61,7 +59,7 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx) ...@@ -61,7 +59,7 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx)
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
hwctx->bitstream_buffers_used = 0; hwctx->bitstream_buffers_used = 0;
}
return 0; return 0;
} }
...@@ -87,15 +85,14 @@ int ff_vdpau_add_buffer(AVCodecContext *avctx, ...@@ -87,15 +85,14 @@ int ff_vdpau_add_buffer(AVCodecContext *avctx,
/* Obsolete non-hwaccel VDPAU support below... */ /* Obsolete non-hwaccel VDPAU support below... */
void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) void ff_vdpau_h264_set_reference_frames(H264Context *h)
{ {
H264Context *h = s->avctx->priv_data;
struct vdpau_render_state *render, *render_ref; struct vdpau_render_state *render, *render_ref;
VdpReferenceFrameH264 *rf, *rf2; VdpReferenceFrameH264 *rf, *rf2;
Picture *pic; Picture *pic;
int i, list, pic_frame_idx; int i, list, pic_frame_idx;
render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
assert(render); assert(render);
rf = &render->info.h264.referenceFrames[0]; rf = &render->info.h264.referenceFrames[0];
...@@ -156,12 +153,9 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) ...@@ -156,12 +153,9 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
} }
} }
void ff_vdpau_add_data_chunk(MpegEncContext *s, void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf, int buf_size)
const uint8_t *buf, int buf_size)
{ {
struct vdpau_render_state *render; struct vdpau_render_state *render = (struct vdpau_render_state*)data;
render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
assert(render); assert(render);
render->bitstream_buffers= av_fast_realloc( render->bitstream_buffers= av_fast_realloc(
...@@ -176,17 +170,16 @@ void ff_vdpau_add_data_chunk(MpegEncContext *s, ...@@ -176,17 +170,16 @@ void ff_vdpau_add_data_chunk(MpegEncContext *s,
render->bitstream_buffers_used++; render->bitstream_buffers_used++;
} }
void ff_vdpau_h264_picture_start(MpegEncContext *s) void ff_vdpau_h264_picture_start(H264Context *h)
{ {
H264Context *h = s->avctx->priv_data;
struct vdpau_render_state *render; struct vdpau_render_state *render;
int i; int i;
render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
assert(render); assert(render);
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; ++i) {
int foc = s->current_picture_ptr->field_poc[i]; int foc = h->cur_pic_ptr->field_poc[i];
if (foc == INT_MAX) if (foc == INT_MAX)
foc = 0; foc = 0;
render->info.h264.field_order_cnt[i] = foc; render->info.h264.field_order_cnt[i] = foc;
...@@ -195,21 +188,20 @@ void ff_vdpau_h264_picture_start(MpegEncContext *s) ...@@ -195,21 +188,20 @@ void ff_vdpau_h264_picture_start(MpegEncContext *s)
render->info.h264.frame_num = h->frame_num; render->info.h264.frame_num = h->frame_num;
} }
void ff_vdpau_h264_picture_complete(MpegEncContext *s) void ff_vdpau_h264_picture_complete(H264Context *h)
{ {
H264Context *h = s->avctx->priv_data;
struct vdpau_render_state *render; struct vdpau_render_state *render;
render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
assert(render); assert(render);
render->info.h264.slice_count = h->slice_num; render->info.h264.slice_count = h->slice_num;
if (render->info.h264.slice_count < 1) if (render->info.h264.slice_count < 1)
return; return;
render->info.h264.is_reference = (s->current_picture_ptr->f.reference & 3) ? VDP_TRUE : VDP_FALSE; render->info.h264.is_reference = (h->cur_pic_ptr->f.reference & 3) ? VDP_TRUE : VDP_FALSE;
render->info.h264.field_pic_flag = s->picture_structure != PICT_FRAME; render->info.h264.field_pic_flag = h->picture_structure != PICT_FRAME;
render->info.h264.bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD; render->info.h264.bottom_field_flag = h->picture_structure == PICT_BOTTOM_FIELD;
render->info.h264.num_ref_frames = h->sps.ref_frame_count; render->info.h264.num_ref_frames = h->sps.ref_frame_count;
render->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !render->info.h264.field_pic_flag; render->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !render->info.h264.field_pic_flag;
render->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred; render->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
...@@ -235,7 +227,7 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s) ...@@ -235,7 +227,7 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s)
memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0])); memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0]));
memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0])); memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0]));
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); ff_h264_draw_horiz_band(h, 0, h->avctx->height);
render->bitstream_buffers_used = 0; render->bitstream_buffers_used = 0;
} }
...@@ -287,7 +279,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, ...@@ -287,7 +279,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
render->info.mpeg.forward_reference = last->surface; render->info.mpeg.forward_reference = last->surface;
} }
ff_vdpau_add_data_chunk(s, buf, buf_size); ff_vdpau_add_data_chunk(s->current_picture_ptr->f.data[0], buf, buf_size);
render->info.mpeg.slice_count = slice_count; render->info.mpeg.slice_count = slice_count;
...@@ -357,7 +349,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, ...@@ -357,7 +349,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
render->info.vc1.forward_reference = last->surface; render->info.vc1.forward_reference = last->surface;
} }
ff_vdpau_add_data_chunk(s, buf, buf_size); ff_vdpau_add_data_chunk(s->current_picture_ptr->f.data[0], buf, buf_size);
render->info.vc1.slice_count = 1; render->info.vc1.slice_count = 1;
...@@ -413,7 +405,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, ...@@ -413,7 +405,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
render->info.mpeg4.forward_reference = last->surface; render->info.mpeg4.forward_reference = last->surface;
} }
ff_vdpau_add_data_chunk(s, buf, buf_size); ff_vdpau_add_data_chunk(s->current_picture_ptr->f.data[0], buf, buf_size);
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0; render->bitstream_buffers_used = 0;
......
...@@ -119,9 +119,8 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx, ...@@ -119,9 +119,8 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx,
{ {
H264Context * const h = avctx->priv_data; H264Context * const h = avctx->priv_data;
AVVDPAUContext *hwctx = avctx->hwaccel_context; AVVDPAUContext *hwctx = avctx->hwaccel_context;
MpegEncContext * const s = &h->s;
VdpPictureInfoH264 *info = &hwctx->info.h264; VdpPictureInfoH264 *info = &hwctx->info.h264;
Picture *pic = s->current_picture_ptr; Picture *pic = h->cur_pic_ptr;
/* init VdpPictureInfoH264 */ /* init VdpPictureInfoH264 */
info->slice_count = 0; info->slice_count = 0;
...@@ -129,8 +128,8 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx, ...@@ -129,8 +128,8 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx,
info->field_order_cnt[1] = h264_foc(pic->field_poc[1]); info->field_order_cnt[1] = h264_foc(pic->field_poc[1]);
info->is_reference = h->nal_ref_idc != 0; info->is_reference = h->nal_ref_idc != 0;
info->frame_num = h->frame_num; info->frame_num = h->frame_num;
info->field_pic_flag = s->picture_structure != PICT_FRAME; info->field_pic_flag = h->picture_structure != PICT_FRAME;
info->bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD; info->bottom_field_flag = h->picture_structure == PICT_BOTTOM_FIELD;
info->num_ref_frames = h->sps.ref_frame_count; info->num_ref_frames = h->sps.ref_frame_count;
info->mb_adaptive_frame_field_flag = h->sps.mb_aff && !info->field_pic_flag; info->mb_adaptive_frame_field_flag = h->sps.mb_aff && !info->field_pic_flag;
info->constrained_intra_pred_flag = h->pps.constrained_intra_pred; info->constrained_intra_pred_flag = h->pps.constrained_intra_pred;
...@@ -185,12 +184,27 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx, ...@@ -185,12 +184,27 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
return 0; return 0;
} }
static int vdpau_h264_end_frame(AVCodecContext *avctx)
{
AVVDPAUContext *hwctx = avctx->hwaccel_context;
H264Context *h = avctx->priv_data;
VdpVideoSurface surf = ff_vdpau_get_surface_id(h->cur_pic_ptr);
hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
hwctx->bitstream_buffers_used, hwctx->bitstream_buffers);
ff_h264_draw_horiz_band(h, 0, h->avctx->height);
hwctx->bitstream_buffers_used = 0;
return 0;
}
AVHWAccel ff_h264_vdpau_hwaccel = { AVHWAccel ff_h264_vdpau_hwaccel = {
.name = "h264_vdpau", .name = "h264_vdpau",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H264, .id = AV_CODEC_ID_H264,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_h264_start_frame, .start_frame = vdpau_h264_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = vdpau_h264_end_frame,
.decode_slice = vdpau_h264_decode_slice, .decode_slice = vdpau_h264_decode_slice,
}; };
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define AVCODEC_VDPAU_INTERNAL_H #define AVCODEC_VDPAU_INTERNAL_H
#include <stdint.h> #include <stdint.h>
#include "h264.h"
#include "mpegvideo.h" #include "mpegvideo.h"
/** Extract VdpVideoSurface from a Picture */ /** Extract VdpVideoSurface from a Picture */
...@@ -35,20 +36,20 @@ static inline uintptr_t ff_vdpau_get_surface_id(Picture *pic) ...@@ -35,20 +36,20 @@ static inline uintptr_t ff_vdpau_get_surface_id(Picture *pic)
int ff_vdpau_common_start_frame(AVCodecContext *avctx, int ff_vdpau_common_start_frame(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size); const uint8_t *buffer, uint32_t size);
int ff_vdpau_common_end_frame(AVCodecContext *avctx); int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
int ff_vdpau_add_buffer(AVCodecContext *avctx, int ff_vdpau_add_buffer(AVCodecContext *avctx,
const uint8_t *buf, uint32_t buf_size); const uint8_t *buf, uint32_t buf_size);
void ff_vdpau_add_data_chunk(MpegEncContext *s, const uint8_t *buf, void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf,
int buf_size); int buf_size);
void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
int buf_size, int slice_count); int buf_size, int slice_count);
void ff_vdpau_h264_picture_start(MpegEncContext *s); void ff_vdpau_h264_picture_start(H264Context *h);
void ff_vdpau_h264_set_reference_frames(MpegEncContext *s); void ff_vdpau_h264_set_reference_frames(H264Context *h);
void ff_vdpau_h264_picture_complete(MpegEncContext *s); void ff_vdpau_h264_picture_complete(H264Context *h);
void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
int buf_size); int buf_size);
......
...@@ -98,7 +98,7 @@ AVHWAccel ff_mpeg1_vdpau_hwaccel = { ...@@ -98,7 +98,7 @@ AVHWAccel ff_mpeg1_vdpau_hwaccel = {
.id = AV_CODEC_ID_MPEG1VIDEO, .id = AV_CODEC_ID_MPEG1VIDEO,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_mpeg_start_frame, .start_frame = vdpau_mpeg_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg_decode_slice, .decode_slice = vdpau_mpeg_decode_slice,
}; };
#endif #endif
...@@ -110,7 +110,7 @@ AVHWAccel ff_mpeg2_vdpau_hwaccel = { ...@@ -110,7 +110,7 @@ AVHWAccel ff_mpeg2_vdpau_hwaccel = {
.id = AV_CODEC_ID_MPEG2VIDEO, .id = AV_CODEC_ID_MPEG2VIDEO,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_mpeg_start_frame, .start_frame = vdpau_mpeg_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg_decode_slice, .decode_slice = vdpau_mpeg_decode_slice,
}; };
#endif #endif
...@@ -92,7 +92,7 @@ AVHWAccel ff_h263_vdpau_hwaccel = { ...@@ -92,7 +92,7 @@ AVHWAccel ff_h263_vdpau_hwaccel = {
.id = AV_CODEC_ID_H263, .id = AV_CODEC_ID_H263,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_mpeg4_start_frame, .start_frame = vdpau_mpeg4_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg4_decode_slice, .decode_slice = vdpau_mpeg4_decode_slice,
}; };
#endif #endif
...@@ -104,7 +104,7 @@ AVHWAccel ff_mpeg4_vdpau_hwaccel = { ...@@ -104,7 +104,7 @@ AVHWAccel ff_mpeg4_vdpau_hwaccel = {
.id = AV_CODEC_ID_MPEG4, .id = AV_CODEC_ID_MPEG4,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_mpeg4_start_frame, .start_frame = vdpau_mpeg4_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg4_decode_slice, .decode_slice = vdpau_mpeg4_decode_slice,
}; };
#endif #endif
...@@ -112,7 +112,7 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = { ...@@ -112,7 +112,7 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = {
.id = AV_CODEC_ID_WMV3, .id = AV_CODEC_ID_WMV3,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_vc1_start_frame, .start_frame = vdpau_vc1_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_vc1_decode_slice, .decode_slice = vdpau_vc1_decode_slice,
}; };
#endif #endif
...@@ -123,6 +123,6 @@ AVHWAccel ff_vc1_vdpau_hwaccel = { ...@@ -123,6 +123,6 @@ AVHWAccel ff_vc1_vdpau_hwaccel = {
.id = AV_CODEC_ID_VC1, .id = AV_CODEC_ID_VC1,
.pix_fmt = AV_PIX_FMT_VDPAU, .pix_fmt = AV_PIX_FMT_VDPAU,
.start_frame = vdpau_vc1_start_frame, .start_frame = vdpau_vc1_start_frame,
.end_frame = ff_vdpau_common_end_frame, .end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_vc1_decode_slice, .decode_slice = vdpau_vc1_decode_slice,
}; };
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