*
* Copyright (C) 2008-2009 Splitted-Desktop Systems
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "vc1.h"
#include "vc1data.h"
-/** Translates FFmpeg MV modes to VA API */
+/** Translate Libav MV modes to VA API */
static int get_VAMvModeVC1(enum MVModes mv_mode)
{
switch (mv_mode) {
return 0;
}
-/** Checks whether the MVTYPEMB bitplane is present */
+/** Check whether the MVTYPEMB bitplane is present */
static inline int vc1_has_MVTYPEMB_bitplane(VC1Context *v)
{
if (v->mv_type_is_raw)
return 0;
- return (v->s.pict_type == FF_P_TYPE &&
- (v->mv_mode == MV_PMODE_MIXED_MV ||
- (v->mv_mode == MV_PMODE_INTENSITY_COMP &&
- v->mv_mode2 == MV_PMODE_MIXED_MV)));
+ return v->s.pict_type == AV_PICTURE_TYPE_P &&
+ (v->mv_mode == MV_PMODE_MIXED_MV ||
+ (v->mv_mode == MV_PMODE_INTENSITY_COMP &&
+ v->mv_mode2 == MV_PMODE_MIXED_MV));
}
-/** Checks whether the SKIPMB bitplane is present */
+/** Check whether the SKIPMB bitplane is present */
static inline int vc1_has_SKIPMB_bitplane(VC1Context *v)
{
if (v->skip_is_raw)
return 0;
- return (v->s.pict_type == FF_P_TYPE ||
- (v->s.pict_type == FF_B_TYPE && !v->bi_type));
+ return v->s.pict_type == AV_PICTURE_TYPE_P ||
+ (v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type);
}
-/** Checks whether the DIRECTMB bitplane is present */
+/** Check whether the DIRECTMB bitplane is present */
static inline int vc1_has_DIRECTMB_bitplane(VC1Context *v)
{
if (v->dmb_is_raw)
return 0;
- return v->s.pict_type == FF_B_TYPE && !v->bi_type;
+ return v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type;
}
-/** Checks whether the ACPRED bitplane is present */
+/** Check whether the ACPRED bitplane is present */
static inline int vc1_has_ACPRED_bitplane(VC1Context *v)
{
if (v->acpred_is_raw)
return 0;
- return (v->profile == PROFILE_ADVANCED &&
- (v->s.pict_type == FF_I_TYPE ||
- (v->s.pict_type == FF_B_TYPE && v->bi_type)));
+ return v->profile == PROFILE_ADVANCED &&
+ (v->s.pict_type == AV_PICTURE_TYPE_I ||
+ (v->s.pict_type == AV_PICTURE_TYPE_B && v->bi_type));
}
/** Check whether the OVERFLAGS bitplane is present */
{
if (v->overflg_is_raw)
return 0;
- return (v->profile == PROFILE_ADVANCED &&
- (v->s.pict_type == FF_I_TYPE ||
- (v->s.pict_type == FF_B_TYPE && v->bi_type)) &&
- (v->overlap && v->pq <= 8) &&
- v->condover == CONDOVER_SELECT);
+ return v->profile == PROFILE_ADVANCED &&
+ (v->s.pict_type == AV_PICTURE_TYPE_I ||
+ (v->s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)) &&
+ (v->overlap && v->pq <= 8) &&
+ v->condover == CONDOVER_SELECT;
}
/** Reconstruct bitstream PTYPE (7.1.1.4, index into Table-35) */
{
MpegEncContext * const s = &v->s;
switch (s->pict_type) {
- case FF_I_TYPE: return 0;
- case FF_P_TYPE: return v->p_frame_skipped ? 4 : 1;
- case FF_B_TYPE: return v->bi_type ? 3 : 2;
+ case AV_PICTURE_TYPE_I: return 0;
+ case AV_PICTURE_TYPE_P: return v->p_frame_skipped ? 4 : 1;
+ case AV_PICTURE_TYPE_B: return v->bi_type ? 3 : 2;
}
return 0;
}
/** Reconstruct bitstream MVMODE (7.1.1.32) */
static inline VAMvModeVC1 vc1_get_MVMODE(VC1Context *v)
{
- if (v->s.pict_type == FF_P_TYPE ||
- (v->s.pict_type == FF_B_TYPE && !v->bi_type))
+ if (v->s.pict_type == AV_PICTURE_TYPE_P ||
+ (v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type))
return get_VAMvModeVC1(v->mv_mode);
return 0;
}
/** Reconstruct bitstream MVMODE2 (7.1.1.33) */
static inline VAMvModeVC1 vc1_get_MVMODE2(VC1Context *v)
{
- if (v->s.pict_type == FF_P_TYPE && v->mv_mode == MV_PMODE_INTENSITY_COMP)
+ if (v->s.pict_type == AV_PICTURE_TYPE_P && v->mv_mode == MV_PMODE_INTENSITY_COMP)
return get_VAMvModeVC1(v->mv_mode2);
return 0;
}
-/** Pack FFmpeg bitplanes into a VABitPlaneBuffer element */
-static inline uint8_t vc1_pack_bitplanes(const uint8_t *ff_bp[3], int x, int y, int stride)
+/** Reconstruct bitstream TTFRM (7.1.1.41, Table-53) */
+static inline int vc1_get_TTFRM(VC1Context *v)
{
- const int n = y * stride + x;
+ switch (v->ttfrm) {
+ case TT_8X8: return 0;
+ case TT_8X4: return 1;
+ case TT_4X8: return 2;
+ case TT_4X4: return 3;
+ }
+ return 0;
+}
+
+/** Pack Libav bitplanes into a VABitPlaneBuffer element */
+static inline void vc1_pack_bitplanes(uint8_t *bitplane, int n, const uint8_t *ff_bp[3], int x, int y, int stride)
+{
+ const int bitplane_index = n / 2;
+ const int ff_bp_index = y * stride + x;
uint8_t v = 0;
if (ff_bp[0])
- v = ff_bp[0][n];
+ v = ff_bp[0][ff_bp_index];
if (ff_bp[1])
- v |= ff_bp[1][n] << 1;
+ v |= ff_bp[1][ff_bp_index] << 1;
if (ff_bp[2])
- v |= ff_bp[2][n] << 2;
- return v;
+ v |= ff_bp[2][ff_bp_index] << 2;
+ bitplane[bitplane_index] = (bitplane[bitplane_index] << 4) | v;
}
static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferVC1 *pic_param;
- dprintf(avctx, "vaapi_vc1_start_frame()\n");
+ av_dlog(avctx, "vaapi_vc1_start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferVC1);
/* Fill in VAPictureParameterBufferVC1 */
- pic_param = ff_vaapi_alloc_picture(vactx, sizeof(VAPictureParameterBufferVC1));
+ pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1));
if (!pic_param)
return -1;
- pic_param->forward_reference_picture = 0xffffffff;
- pic_param->backward_reference_picture = 0xffffffff;
- pic_param->inloop_decoded_picture = 0xffffffff;
+ pic_param->forward_reference_picture = VA_INVALID_ID;
+ pic_param->backward_reference_picture = VA_INVALID_ID;
+ pic_param->inloop_decoded_picture = VA_INVALID_ID;
pic_param->sequence_fields.value = 0; /* reset all bits */
pic_param->sequence_fields.bits.pulldown = v->broadcast;
pic_param->sequence_fields.bits.interlace = v->interlace;
pic_param->sequence_fields.bits.syncmarker = s->resync_marker;
pic_param->sequence_fields.bits.rangered = v->rangered;
pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames;
+#if VA_CHECK_VERSION(0,32,0)
+ pic_param->sequence_fields.bits.profile = v->profile;
+#endif
pic_param->coded_width = s->avctx->coded_width;
pic_param->coded_height = s->avctx->coded_height;
pic_param->entrypoint_fields.value = 0; /* reset all bits */
pic_param->transform_fields.value = 0; /* reset all bits */
pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform;
pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf;
- pic_param->transform_fields.bits.frame_level_transform_type = v->ttfrm;
+ pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(v);
pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index;
pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index;
pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index;
switch (s->pict_type) {
- case FF_B_TYPE:
- pic_param->backward_reference_picture = ff_vaapi_get_surface(&s->next_picture);
+ case AV_PICTURE_TYPE_B:
+ pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture);
// fall-through
- case FF_P_TYPE:
- pic_param->forward_reference_picture = ff_vaapi_get_surface(&s->last_picture);
+ case AV_PICTURE_TYPE_P:
+ pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture);
break;
}
int x, y, n;
switch (s->pict_type) {
- case FF_P_TYPE:
+ case AV_PICTURE_TYPE_P:
ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL;
ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL;
break;
- case FF_B_TYPE:
+ case AV_PICTURE_TYPE_B:
if (!v->bi_type) {
ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL;
break;
}
/* fall-through (BI-type) */
- case FF_I_TYPE:
+ case AV_PICTURE_TYPE_I:
ff_bp[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */
ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL;
ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL;
break;
}
- bitplane = ff_vaapi_alloc_bitplane(vactx, s->mb_height * ((s->mb_width + 1) / 2));
+ bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2);
if (!bitplane)
return -1;
n = 0;
- for (y = 0; y < s->mb_height; y++) {
- for (x = 0; x < s->mb_width; x += 2) {
- bitplane[n] = vc1_pack_bitplanes(ff_bp, x+1, y, s->mb_stride);
- bitplane[n] |= (vc1_pack_bitplanes(ff_bp, x, y, s->mb_stride) << 4);
- ++n;
- }
- }
+ for (y = 0; y < s->mb_height; y++)
+ for (x = 0; x < s->mb_width; x++, n++)
+ vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride);
+ if (n & 1) /* move last nibble to the high order */
+ bitplane[n/2] <<= 4;
}
return 0;
}
MpegEncContext * const s = &v->s;
VASliceParameterBufferVC1 *slice_param;
- dprintf(avctx, "vaapi_vc1_decode_slice(): buffer %p, size %d\n", buffer, size);
+ av_dlog(avctx, "vaapi_vc1_decode_slice(): buffer %p, size %d\n", buffer, size);
/* Current bit buffer is beyond any marker for VC-1, so skip it */
if (avctx->codec_id == CODEC_ID_VC1 && IS_MARKER(AV_RB32(buffer))) {
}
#if CONFIG_WMV3_VAAPI_HWACCEL
-AVHWAccel wmv3_vaapi_hwaccel = {
+AVHWAccel ff_wmv3_vaapi_hwaccel = {
.name = "wmv3_vaapi",
- .type = CODEC_TYPE_VIDEO,
+ .type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_WMV3,
.pix_fmt = PIX_FMT_VAAPI_VLD,
- .capabilities = 0,
.start_frame = vaapi_vc1_start_frame,
.end_frame = vaapi_vc1_end_frame,
.decode_slice = vaapi_vc1_decode_slice,
- .priv_data_size = 0,
};
#endif
-AVHWAccel vc1_vaapi_hwaccel = {
+AVHWAccel ff_vc1_vaapi_hwaccel = {
.name = "vc1_vaapi",
- .type = CODEC_TYPE_VIDEO,
+ .type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_VC1,
.pix_fmt = PIX_FMT_VAAPI_VLD,
- .capabilities = 0,
.start_frame = vaapi_vc1_start_frame,
.end_frame = vaapi_vc1_end_frame,
.decode_slice = vaapi_vc1_decode_slice,
- .priv_data_size = 0,
};