Add old patches to FFmpeg:
[vaapi:mplayer.git] / patches / 0002-Add-compatibility-with-original-VA-API-0.29.patch
1 From 9d15e003b4a981dbe21f197e7ee91f7d86f5b818 Mon Sep 17 00:00:00 2001
2 From: Gwenole Beauchesne <gbeauchesne@splitted-desktop.com>
3 Date: Fri, 12 Feb 2010 11:03:00 +0000
4 Subject: [PATCH] Add compatibility with original VA-API 0.29.
5
6 ---
7  configure                          |   23 ++++-
8  ffmpeg/libavcodec/vaapi_compat.h   |   96 +++++++++++++++++
9  ffmpeg/libavcodec/vaapi_h264.c     |   76 +++++++-------
10  ffmpeg/libavcodec/vaapi_internal.h |    6 +
11  ffmpeg/libavcodec/vaapi_mpeg2.c    |   38 ++++---
12  ffmpeg/libavcodec/vaapi_mpeg4.c    |   74 +++++++------
13  ffmpeg/libavcodec/vaapi_vc1.c      |  208 ++++++++++++++++++------------------
14  libvo/vo_vaapi.c                   |    4 +
15  8 files changed, 328 insertions(+), 197 deletions(-)
16  create mode 100644 ffmpeg/libavcodec/vaapi_compat.h
17
18 diff --git a/configure b/configure
19 index 45e4574..b1ff778 100755
20 --- a/configure
21 +++ b/configure
22 @@ -5835,21 +5835,36 @@ if test -n "$_vaapiprefix"; then
23  fi
24  if test "$_vaapi" = yes -o "$_vaapi" = auto; then
25    _vaapi=no
26 +  _vaapi_old=no
27    cat > $TMPC <<EOF
28  #include <va/va_x11.h>
29  int main(void) { (void) vaGetDisplay(0); return 0; }
30  EOF
31 -  cc_check $_vaapiinc $_vaapilib -lva-x11 && _vaapi=yes
32 +  cc_check $_vaapiinc $_vaapilib -lva-x11 && _vaapi=yes || {
33 +    cat > $TMPC <<EOF
34 +#include <va_x11.h>
35 +int main(void) { (void) vaGetDisplay(0); return 0; }
36 +EOF
37 +    cc_check $_vaapiinc $_vaapilib -lva && _vaapi=yes _vaapi_old=yes
38 +  }
39  fi
40  
41  if test "$_vaapi" = yes ; then
42    def_vaapi='#define CONFIG_VAAPI 1'
43    extra_cflags="$extra_cflags $_vaapiinc"
44 -  libs_mencoder="$libs_mencoder $_vaapilib -lva"
45 -  libs_mplayer="$libs_mplayer $_vaapilib -lva -lva-x11"
46 +  if test "$_vaapi_old" = no ; then
47 +    def_vaapi_old='#define CONFIG_VAAPI_OLD 0'
48 +    libs_mencoder="$libs_mencoder $_vaapilib -lva"
49 +    libs_mplayer="$libs_mplayer $_vaapilib -lva -lva-x11"
50 +  else
51 +    def_vaapi_old='#define CONFIG_VAAPI_OLD 1'
52 +    _mencoder="no"
53 +    libs_mplayer="$libs_mplayer $_vaapilib -lva"
54 +  fi
55    vomodules="vaapi $vomodules"
56  else
57    def_vaapi='#define CONFIG_VAAPI 0'
58 +  def_vaapi_old='#define CONFIG_VAAPI_OLD 0'
59    novomodules="vaapi $novomodules"
60    libavhwaccels=`echo $libavhwaccels | sed -e "s/\(MPEG[124]\|H26[34]\|WMV3\|VC1\)_VAAPI_HWACCEL//g"`
61  fi
62 @@ -8298,6 +8313,7 @@ CONFIG_MUXERS   = $_mencoder
63  CONFIG_POSTPROC = yes
64  CONFIG_RTPDEC   = $networking
65  CONFIG_VAAPI    = $_vaapi
66 +CONFIG_VAAPI_OLD= $_vaapi_old
67  CONFIG_VDPAU    = $_vdpau
68  CONFIG_XRENDER = $_xrender
69  CONFIG_XVMC     = $_xvmc
70 @@ -8675,6 +8691,7 @@ $def_tdfxvid
71  $def_tga
72  $def_v4l2
73  $def_vaapi
74 +$def_vaapi_old
75  $def_vaapi_glx
76  $def_vdpau
77  $def_vesa
78 diff --git a/ffmpeg/libavcodec/vaapi_compat.h b/ffmpeg/libavcodec/vaapi_compat.h
79 new file mode 100644
80 index 0000000..2f7ece8
81 --- /dev/null
82 +++ b/ffmpeg/libavcodec/vaapi_compat.h
83 @@ -0,0 +1,96 @@
84 +/*
85 + * Video Acceleration API (video decoding)
86 + * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
87 + *
88 + * Copyright (C) 2008-2009 Splitted-Desktop Systems
89 + *
90 + * This file is part of FFmpeg.
91 + *
92 + * FFmpeg is free software; you can redistribute it and/or
93 + * modify it under the terms of the GNU Lesser General Public
94 + * License as published by the Free Software Foundation; either
95 + * version 2.1 of the License, or (at your option) any later version.
96 + *
97 + * FFmpeg is distributed in the hope that it will be useful,
98 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
99 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
100 + * Lesser General Public License for more details.
101 + *
102 + * You should have received a copy of the GNU Lesser General Public
103 + * License along with FFmpeg; if not, write to the Free Software
104 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
105 + */
106 +
107 +#ifndef AVCODEC_VAAPI_COMPAT_H
108 +#define AVCODEC_VAAPI_COMPAT_H
109 +
110 +/* Compatibility glue with original VA-API 0.29 */
111 +#if CONFIG_VAAPI_OLD
112 +typedef struct _VASliceParameterBufferBase {
113 +    unsigned int slice_data_size;
114 +    unsigned int slice_data_offset;
115 +    unsigned int slice_data_flag;
116 +} VASliceParameterBufferBase;
117 +#endif
118 +
119 +#ifndef VA_SDS_VERSION
120 +#define VA_SDS_VERSION 0
121 +#endif
122 +
123 +#ifndef VA_CHECK_VERSION
124 +#define VA_MAJOR_VERSION 0
125 +#define VA_MINOR_VERSION 29
126 +#define VA_CHECK_VERSION(major,minor,micro) \
127 +        (VA_MAJOR_VERSION > (major) || \
128 +         (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \
129 +         (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro)))
130 +#endif
131 +
132 +#ifndef VA_FOURCC
133 +#define VA_FOURCC(ch0, ch1, ch2, ch3)           \
134 +    ((uint32_t)(uint8_t)(ch0) |                 \
135 +     ((uint32_t)(uint8_t)(ch1) << 8) |          \
136 +     ((uint32_t)(uint8_t)(ch2) << 16) |         \
137 +     ((uint32_t)(uint8_t)(ch3) << 24 ))
138 +#endif
139 +
140 +#ifndef VA_INVALID_ID
141 +#define VA_INVALID_ID           0xffffffff
142 +#endif
143 +#ifndef VA_INVALID_SURFACE
144 +#define VA_INVALID_SURFACE      VA_INVALID_ID
145 +#endif
146 +
147 +/* Compatibility glue with VA-API >= 0.31 */
148 +#if VA_CHECK_VERSION(0,31,0)
149 +#define vaSyncSurface(dpy, context, surface) (vaSyncSurface)((dpy), (surface))
150 +#define vaPutImage2             vaPutImage
151 +#define vaAssociateSubpicture2  vaAssociateSubpicture
152 +#endif
153 +
154 +/* Used in codec implementation to set up the right bit-fields */
155 +#if CONFIG_VAAPI_OLD
156 +# define BFV(a, b)              a
157 +# define BFM(a, b, c)           c
158 +# define BFMP(p, a, b, c)       p##_##c
159 +# define NEW(x)                 /* nothing */
160 +#else
161 +# define BFV(a, b)              a.b
162 +# define BFM(a, b, c)           a.b.c
163 +# define BFMP(p, a, b, c)       a.b.c
164 +# define NEW(x)                 x
165 +#endif
166 +
167 +#if CONFIG_VAAPI_OLD
168 +# define V_raw_coding           raw_coding_flag
169 +# define M_raw_coding           raw_coding
170 +# define V_bitplane_present     bitplane_present_flag
171 +# define M_bitplane_present     bitplane_present
172 +#else
173 +# define V_raw_coding           raw_coding
174 +# define M_raw_coding           raw_coding
175 +# define V_bitplane_present     bitplane_present
176 +# define M_bitplane_present     bitplane_present
177 +#endif
178 +
179 +#endif /* AVCODEC_VAAPI_COMPAT_H */
180 diff --git a/ffmpeg/libavcodec/vaapi_h264.c b/ffmpeg/libavcodec/vaapi_h264.c
181 index 739bce7..27a0ee4 100644
182 --- a/ffmpeg/libavcodec/vaapi_h264.c
183 +++ b/ffmpeg/libavcodec/vaapi_h264.c
184 @@ -110,8 +110,8 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic,
185      if (pic_structure == 0)
186          pic_structure = pic->reference;
187  
188 -    va_pic->picture_id = ff_vaapi_get_surface_id(pic);
189 -    va_pic->frame_idx  = pic->long_ref ? pic->pic_id : pic->frame_num;
190 +    va_pic->picture_id    = ff_vaapi_get_surface_id(pic);
191 +    NEW(va_pic->frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num);
192  
193      va_pic->flags      = 0;
194      if (pic_structure != PICT_FRAME)
195 @@ -304,42 +304,42 @@ static int start_frame(AVCodecContext          *avctx,
196      fill_vaapi_pic(&pic_param->CurrPic, s->current_picture_ptr, s->picture_structure);
197      if (fill_vaapi_ReferenceFrames(pic_param, h) < 0)
198          return -1;
199 -    pic_param->picture_width_in_mbs_minus1                      = s->mb_width - 1;
200 -    pic_param->picture_height_in_mbs_minus1                     = s->mb_height - 1;
201 -    pic_param->bit_depth_luma_minus8                            = h->sps.bit_depth_luma - 8;
202 -    pic_param->bit_depth_chroma_minus8                          = h->sps.bit_depth_chroma - 8;
203 -    pic_param->num_ref_frames                                   = h->sps.ref_frame_count;
204 -    pic_param->seq_fields.value                                 = 0; /* reset all bits */
205 -    pic_param->seq_fields.bits.chroma_format_idc                = h->sps.chroma_format_idc;
206 -    pic_param->seq_fields.bits.residual_colour_transform_flag   = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */
207 -    pic_param->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag;
208 -    pic_param->seq_fields.bits.frame_mbs_only_flag              = h->sps.frame_mbs_only_flag;
209 -    pic_param->seq_fields.bits.mb_adaptive_frame_field_flag     = h->sps.mb_aff;
210 -    pic_param->seq_fields.bits.direct_8x8_inference_flag        = h->sps.direct_8x8_inference_flag;
211 -    pic_param->seq_fields.bits.MinLumaBiPredSize8x8             = h->sps.level_idc >= 31; /* A.3.3.2 */
212 -    pic_param->seq_fields.bits.log2_max_frame_num_minus4        = h->sps.log2_max_frame_num - 4;
213 -    pic_param->seq_fields.bits.pic_order_cnt_type               = h->sps.poc_type;
214 -    pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
215 -    pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
216 -    pic_param->num_slice_groups_minus1                          = h->pps.slice_group_count - 1;
217 -    pic_param->slice_group_map_type                             = h->pps.mb_slice_group_map_type;
218 -    pic_param->slice_group_change_rate_minus1                   = 0; /* XXX: unimplemented in FFmpeg */
219 -    pic_param->pic_init_qp_minus26                              = h->pps.init_qp - 26;
220 -    pic_param->pic_init_qs_minus26                              = h->pps.init_qs - 26;
221 -    pic_param->chroma_qp_index_offset                           = h->pps.chroma_qp_index_offset[0];
222 -    pic_param->second_chroma_qp_index_offset                    = h->pps.chroma_qp_index_offset[1];
223 -    pic_param->pic_fields.value                                 = 0; /* reset all bits */
224 -    pic_param->pic_fields.bits.entropy_coding_mode_flag         = h->pps.cabac;
225 -    pic_param->pic_fields.bits.weighted_pred_flag               = h->pps.weighted_pred;
226 -    pic_param->pic_fields.bits.weighted_bipred_idc              = h->pps.weighted_bipred_idc;
227 -    pic_param->pic_fields.bits.transform_8x8_mode_flag          = h->pps.transform_8x8_mode;
228 -    pic_param->pic_fields.bits.field_pic_flag                   = s->picture_structure != PICT_FRAME;
229 -    pic_param->pic_fields.bits.constrained_intra_pred_flag      = h->pps.constrained_intra_pred;
230 -    pic_param->pic_fields.bits.pic_order_present_flag           = h->pps.pic_order_present;
231 -    pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
232 -    pic_param->pic_fields.bits.redundant_pic_cnt_present_flag   = h->pps.redundant_pic_cnt_present;
233 -    pic_param->pic_fields.bits.reference_pic_flag               = h->nal_ref_idc != 0;
234 -    pic_param->frame_num                                        = h->frame_num;
235 +    pic_param->picture_width_in_mbs_minus1                              = s->mb_width - 1;
236 +    pic_param->picture_height_in_mbs_minus1                             = s->mb_height - 1;
237 +    pic_param->bit_depth_luma_minus8                                    = h->sps.bit_depth_luma - 8;
238 +    pic_param->bit_depth_chroma_minus8                                  = h->sps.bit_depth_chroma - 8;
239 +    pic_param->num_ref_frames                                           = h->sps.ref_frame_count;
240 +    pic_param->BFV(seq_fields,value)                                    = 0; /* reset all bits */
241 +    pic_param->BFM(seq_fields,bits,chroma_format_idc)                   = h->sps.chroma_format_idc;
242 +    pic_param->BFM(seq_fields,bits,residual_colour_transform_flag)      = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */
243 +    NEW(pic_param->BFM(seq_fields,bits,gaps_in_frame_num_value_allowed_flag) = h->sps.gaps_in_frame_num_allowed_flag);
244 +    pic_param->BFM(seq_fields,bits,frame_mbs_only_flag)                 = h->sps.frame_mbs_only_flag;
245 +    pic_param->BFM(seq_fields,bits,mb_adaptive_frame_field_flag)        = h->sps.mb_aff;
246 +    pic_param->BFM(seq_fields,bits,direct_8x8_inference_flag)           = h->sps.direct_8x8_inference_flag;
247 +    pic_param->BFM(seq_fields,bits,MinLumaBiPredSize8x8)                = h->sps.level_idc >= 31; /* A.3.3.2 */
248 +    NEW(pic_param->BFM(seq_fields,bits,log2_max_frame_num_minus4)       = h->sps.log2_max_frame_num - 4);
249 +    NEW(pic_param->BFM(seq_fields,bits,pic_order_cnt_type)              = h->sps.poc_type);
250 +    NEW(pic_param->BFM(seq_fields,bits,log2_max_pic_order_cnt_lsb_minus4) = h->sps.log2_max_poc_lsb - 4);
251 +    NEW(pic_param->BFM(seq_fields,bits,delta_pic_order_always_zero_flag)  = h->sps.delta_pic_order_always_zero_flag);
252 +    pic_param->num_slice_groups_minus1                                  = h->pps.slice_group_count - 1;
253 +    pic_param->slice_group_map_type                                     = h->pps.mb_slice_group_map_type;
254 +    NEW(pic_param->slice_group_change_rate_minus1                       = 0); /* XXX: unimplemented in FFmpeg */
255 +    pic_param->pic_init_qp_minus26                                      = h->pps.init_qp - 26;
256 +    NEW(pic_param->pic_init_qs_minus26                                  = h->pps.init_qs - 26);
257 +    pic_param->chroma_qp_index_offset                                   = h->pps.chroma_qp_index_offset[0];
258 +    pic_param->second_chroma_qp_index_offset                            = h->pps.chroma_qp_index_offset[1];
259 +    pic_param->BFV(pic_fields,value)                                    = 0; /* reset all bits */
260 +    pic_param->BFM(pic_fields,bits,entropy_coding_mode_flag)            = h->pps.cabac;
261 +    pic_param->BFM(pic_fields,bits,weighted_pred_flag)                  = h->pps.weighted_pred;
262 +    pic_param->BFM(pic_fields,bits,weighted_bipred_idc)                 = h->pps.weighted_bipred_idc;
263 +    pic_param->BFM(pic_fields,bits,transform_8x8_mode_flag)             = h->pps.transform_8x8_mode;
264 +    pic_param->BFM(pic_fields,bits,field_pic_flag)                      = s->picture_structure != PICT_FRAME;
265 +    pic_param->BFM(pic_fields,bits,constrained_intra_pred_flag)         = h->pps.constrained_intra_pred;
266 +    NEW(pic_param->BFM(pic_fields,bits,pic_order_present_flag)          = h->pps.pic_order_present);
267 +    NEW(pic_param->BFM(pic_fields,bits,deblocking_filter_control_present_flag) = h->pps.deblocking_filter_parameters_present);
268 +    NEW(pic_param->BFM(pic_fields,bits,redundant_pic_cnt_present_flag)  = h->pps.redundant_pic_cnt_present);
269 +    NEW(pic_param->BFM(pic_fields,bits,reference_pic_flag)              = h->nal_ref_idc != 0);
270 +    pic_param->frame_num                                                = h->frame_num;
271  
272      /* Fill in VAIQMatrixBufferH264. */
273      iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferH264));
274 diff --git a/ffmpeg/libavcodec/vaapi_internal.h b/ffmpeg/libavcodec/vaapi_internal.h
275 index 2c0fdf9..ff83b96 100644
276 --- a/ffmpeg/libavcodec/vaapi_internal.h
277 +++ b/ffmpeg/libavcodec/vaapi_internal.h
278 @@ -24,8 +24,14 @@
279  #ifndef AVCODEC_VAAPI_INTERNAL_H
280  #define AVCODEC_VAAPI_INTERNAL_H
281  
282 +#include "config.h"
283 +#if CONFIG_VAAPI_OLD
284 +#include <va.h>
285 +#else
286  #include <va/va.h>
287 +#endif
288  #include "vaapi.h"
289 +#include "vaapi_compat.h"
290  #include "avcodec.h"
291  #include "mpegvideo.h"
292  
293 diff --git a/ffmpeg/libavcodec/vaapi_mpeg2.c b/ffmpeg/libavcodec/vaapi_mpeg2.c
294 index 2e870dc..277c7a5 100644
295 --- a/ffmpeg/libavcodec/vaapi_mpeg2.c
296 +++ b/ffmpeg/libavcodec/vaapi_mpeg2.c
297 @@ -52,24 +52,24 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_
298      pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG2));
299      if (!pic_param)
300          return -1;
301 -    pic_param->horizontal_size                                  = s->width;
302 -    pic_param->vertical_size                                    = s->height;
303 -    pic_param->forward_reference_picture                        = VA_INVALID_ID;
304 -    pic_param->backward_reference_picture                       = VA_INVALID_ID;
305 -    pic_param->picture_coding_type                              = s->pict_type;
306 -    pic_param->f_code                                           = mpeg2_get_f_code(s);
307 -    pic_param->picture_coding_extension.value                   = 0; /* reset all bits */
308 -    pic_param->picture_coding_extension.bits.intra_dc_precision = s->intra_dc_precision;
309 -    pic_param->picture_coding_extension.bits.picture_structure  = s->picture_structure;
310 -    pic_param->picture_coding_extension.bits.top_field_first    = s->top_field_first;
311 -    pic_param->picture_coding_extension.bits.frame_pred_frame_dct = s->frame_pred_frame_dct;
312 -    pic_param->picture_coding_extension.bits.concealment_motion_vectors = s->concealment_motion_vectors;
313 -    pic_param->picture_coding_extension.bits.q_scale_type       = s->q_scale_type;
314 -    pic_param->picture_coding_extension.bits.intra_vlc_format   = s->intra_vlc_format;
315 -    pic_param->picture_coding_extension.bits.alternate_scan     = s->alternate_scan;
316 -    pic_param->picture_coding_extension.bits.repeat_first_field = s->repeat_first_field;
317 -    pic_param->picture_coding_extension.bits.progressive_frame  = s->progressive_frame;
318 -    pic_param->picture_coding_extension.bits.is_first_field     = mpeg2_get_is_frame_start(s);
319 +    pic_param->horizontal_size                                               = s->width;
320 +    pic_param->vertical_size                                                 = s->height;
321 +    pic_param->forward_reference_picture                                     = VA_INVALID_ID;
322 +    pic_param->backward_reference_picture                                    = VA_INVALID_ID;
323 +    pic_param->picture_coding_type                                           = s->pict_type;
324 +    pic_param->f_code                                                        = mpeg2_get_f_code(s);
325 +    pic_param->BFV(picture_coding_extension,value)                           = 0; /* reset all bits */
326 +    pic_param->BFM(picture_coding_extension,bits,intra_dc_precision)         = s->intra_dc_precision;
327 +    pic_param->BFM(picture_coding_extension,bits,picture_structure)          = s->picture_structure;
328 +    pic_param->BFM(picture_coding_extension,bits,top_field_first)            = s->top_field_first;
329 +    pic_param->BFM(picture_coding_extension,bits,frame_pred_frame_dct)       = s->frame_pred_frame_dct;
330 +    pic_param->BFM(picture_coding_extension,bits,concealment_motion_vectors) = s->concealment_motion_vectors;
331 +    pic_param->BFM(picture_coding_extension,bits,q_scale_type)               = s->q_scale_type;
332 +    pic_param->BFM(picture_coding_extension,bits,intra_vlc_format)           = s->intra_vlc_format;
333 +    pic_param->BFM(picture_coding_extension,bits,alternate_scan)             = s->alternate_scan;
334 +    pic_param->BFM(picture_coding_extension,bits,repeat_first_field)         = s->repeat_first_field;
335 +    pic_param->BFM(picture_coding_extension,bits,progressive_frame)          = s->progressive_frame;
336 +    pic_param->BFM(picture_coding_extension,bits,is_first_field)             = mpeg2_get_is_frame_start(s);
337  
338      switch (s->pict_type) {
339      case FF_B_TYPE:
340 @@ -131,7 +131,9 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
341      if (!slice_param)
342          return -1;
343      slice_param->macroblock_offset              = macroblock_offset;
344 +#if VA_CHECK_VERSION(0,31,1) || (VA_CHECK_VERSION(0,31,0) && VA_SDS_VERSION >= 3)
345      slice_param->slice_horizontal_position      = s->mb_x;
346 +#endif
347      slice_param->slice_vertical_position        = s->mb_y;
348      slice_param->quantiser_scale_code           = quantiser_scale_code;
349      slice_param->intra_slice_flag               = intra_slice_flag;
350 diff --git a/ffmpeg/libavcodec/vaapi_mpeg4.c b/ffmpeg/libavcodec/vaapi_mpeg4.c
351 index 8f02e91..557ae6c 100644
352 --- a/ffmpeg/libavcodec/vaapi_mpeg4.c
353 +++ b/ffmpeg/libavcodec/vaapi_mpeg4.c
354 @@ -55,42 +55,46 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
355      pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG4));
356      if (!pic_param)
357          return -1;
358 -    pic_param->vop_width                                = s->width;
359 -    pic_param->vop_height                               = s->height;
360 -    pic_param->forward_reference_picture                = VA_INVALID_ID;
361 -    pic_param->backward_reference_picture               = VA_INVALID_ID;
362 -    pic_param->vol_fields.value                         = 0; /* reset all bits */
363 -    pic_param->vol_fields.bits.short_video_header       = avctx->codec->id == CODEC_ID_H263;
364 -    pic_param->vol_fields.bits.chroma_format            = CHROMA_420;
365 -    pic_param->vol_fields.bits.interlaced               = !s->progressive_sequence;
366 -    pic_param->vol_fields.bits.obmc_disable             = 1;
367 -    pic_param->vol_fields.bits.sprite_enable            = s->vol_sprite_usage;
368 -    pic_param->vol_fields.bits.sprite_warping_accuracy  = s->sprite_warping_accuracy;
369 -    pic_param->vol_fields.bits.quant_type               = s->mpeg_quant;
370 -    pic_param->vol_fields.bits.quarter_sample           = s->quarter_sample;
371 -    pic_param->vol_fields.bits.data_partitioned         = s->data_partitioning;
372 -    pic_param->vol_fields.bits.reversible_vlc           = s->rvlc;
373 -    pic_param->vol_fields.bits.resync_marker_disable    = !s->resync_marker;
374 -    pic_param->no_of_sprite_warping_points              = s->num_sprite_warping_points;
375 +    pic_param->vop_width                                               = s->width;
376 +    pic_param->vop_height                                              = s->height;
377 +    pic_param->forward_reference_picture                               = VA_INVALID_ID;
378 +    pic_param->backward_reference_picture                              = VA_INVALID_ID;
379 +    pic_param->BFV(vol_fields,value)                                   = 0; /* reset all bits */
380 +    pic_param->BFM(vol_fields,bits,short_video_header)                 = avctx->codec->id == CODEC_ID_H263;
381 +    pic_param->BFM(vol_fields,bits,chroma_format)                      = CHROMA_420;
382 +    pic_param->BFM(vol_fields,bits,interlaced)                         = !s->progressive_sequence;
383 +    pic_param->BFM(vol_fields,bits,obmc_disable)                       = 1;
384 +    pic_param->BFM(vol_fields,bits,sprite_enable)                      = s->vol_sprite_usage;
385 +    pic_param->BFM(vol_fields,bits,sprite_warping_accuracy)            = s->sprite_warping_accuracy;
386 +    pic_param->BFM(vol_fields,bits,quant_type)                         = s->mpeg_quant;
387 +    pic_param->BFM(vol_fields,bits,quarter_sample)                     = s->quarter_sample;
388 +    pic_param->BFM(vol_fields,bits,data_partitioned)                   = s->data_partitioning;
389 +    pic_param->BFM(vol_fields,bits,reversible_vlc)                     = s->rvlc;
390 +#if VA_CHECK_VERSION(0,31,1) || (VA_CHECK_VERSION(0,31,0) && VA_SDS_VERSION >= 4)
391 +    pic_param->BFM(vol_fields,bits,resync_marker_disable)              = !s->resync_marker;
392 +#endif
393 +    pic_param->no_of_sprite_warping_points                             = s->num_sprite_warping_points;
394      for (i = 0; i < s->num_sprite_warping_points && i < 3; i++) {
395 -        pic_param->sprite_trajectory_du[i]              = s->sprite_traj[i][0];
396 -        pic_param->sprite_trajectory_dv[i]              = s->sprite_traj[i][1];
397 +        pic_param->sprite_trajectory_du[i]                             = s->sprite_traj[i][0];
398 +        pic_param->sprite_trajectory_dv[i]                             = s->sprite_traj[i][1];
399      }
400 -    pic_param->quant_precision                          = s->quant_precision;
401 -    pic_param->vop_fields.value                         = 0; /* reset all bits */
402 -    pic_param->vop_fields.bits.vop_coding_type          = s->pict_type - FF_I_TYPE;
403 -    pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == FF_B_TYPE ? s->next_picture.pict_type - FF_I_TYPE : 0;
404 -    pic_param->vop_fields.bits.vop_rounding_type        = s->no_rounding;
405 -    pic_param->vop_fields.bits.intra_dc_vlc_thr         = mpeg4_get_intra_dc_vlc_thr(s);
406 -    pic_param->vop_fields.bits.top_field_first          = s->top_field_first;
407 -    pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan;
408 -    pic_param->vop_fcode_forward                        = s->f_code;
409 -    pic_param->vop_fcode_backward                       = s->b_code;
410 -    pic_param->vop_time_increment_resolution            = avctx->time_base.den;
411 -    pic_param->num_macroblocks_in_gob                   = s->mb_width * ff_h263_get_gob_height(s);
412 -    pic_param->num_gobs_in_vop                          = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob;
413 -    pic_param->TRB                                      = s->pb_time;
414 -    pic_param->TRD                                      = s->pp_time;
415 +    pic_param->quant_precision                                         = s->quant_precision;
416 +    pic_param->BFV(vop_fields,value)                                   = 0; /* reset all bits */
417 +    pic_param->BFM(vop_fields,bits,vop_coding_type)                    = s->pict_type - FF_I_TYPE;
418 +    pic_param->BFM(vop_fields,bits,backward_reference_vop_coding_type) = s->pict_type == FF_B_TYPE ? s->next_picture.pict_type - FF_I_TYPE : 0;
419 +    pic_param->BFM(vop_fields,bits,vop_rounding_type)                  = s->no_rounding;
420 +    pic_param->BFM(vop_fields,bits,intra_dc_vlc_thr)                   = mpeg4_get_intra_dc_vlc_thr(s);
421 +    pic_param->BFM(vop_fields,bits,top_field_first)                    = s->top_field_first;
422 +    pic_param->BFM(vop_fields,bits,alternate_vertical_scan_flag)       = s->alternate_scan;
423 +    pic_param->vop_fcode_forward                                       = s->f_code;
424 +    pic_param->vop_fcode_backward                                      = s->b_code;
425 +#if VA_CHECK_VERSION(0,31,1) || (VA_CHECK_VERSION(0,31,0) && VA_SDS_VERSION >= 4)
426 +    pic_param->vop_time_increment_resolution                            = avctx->time_base.den;
427 +#endif
428 +    pic_param->num_macroblocks_in_gob                                  = s->mb_width * ff_h263_get_gob_height(s);
429 +    pic_param->num_gobs_in_vop                                         = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob;
430 +    pic_param->TRB                                                     = s->pb_time;
431 +    pic_param->TRD                                                     = s->pp_time;
432  
433      if (s->pict_type == FF_B_TYPE)
434          pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture);
435 @@ -99,7 +103,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
436  
437      /* Fill in VAIQMatrixBufferMPEG4 */
438      /* Only the first inverse quantisation method uses the weighthing matrices */
439 -    if (pic_param->vol_fields.bits.quant_type) {
440 +    if (pic_param->BFM(vol_fields,bits,quant_type)) {
441          iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG4));
442          if (!iq_matrix)
443              return -1;
444 diff --git a/ffmpeg/libavcodec/vaapi_vc1.c b/ffmpeg/libavcodec/vaapi_vc1.c
445 index 34e9056..b29e50e 100644
446 --- a/ffmpeg/libavcodec/vaapi_vc1.c
447 +++ b/ffmpeg/libavcodec/vaapi_vc1.c
448 @@ -146,101 +146,103 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t
449      pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1));
450      if (!pic_param)
451          return -1;
452 -    pic_param->forward_reference_picture                            = VA_INVALID_ID;
453 -    pic_param->backward_reference_picture                           = VA_INVALID_ID;
454 -    pic_param->inloop_decoded_picture                               = VA_INVALID_ID;
455 -    pic_param->sequence_fields.value                                = 0; /* reset all bits */
456 -    pic_param->sequence_fields.bits.pulldown                        = v->broadcast;
457 -    pic_param->sequence_fields.bits.interlace                       = v->interlace;
458 -    pic_param->sequence_fields.bits.tfcntrflag                      = v->tfcntrflag;
459 -    pic_param->sequence_fields.bits.finterpflag                     = v->finterpflag;
460 -    pic_param->sequence_fields.bits.psf                             = v->psf;
461 -    pic_param->sequence_fields.bits.multires                        = v->multires;
462 -    pic_param->sequence_fields.bits.overlap                         = v->overlap;
463 -    pic_param->sequence_fields.bits.syncmarker                      = s->resync_marker;
464 -    pic_param->sequence_fields.bits.rangered                        = v->rangered;
465 -    pic_param->sequence_fields.bits.max_b_frames                    = s->avctx->max_b_frames;
466 -    pic_param->sequence_fields.bits.profile                         = v->profile;
467 -    pic_param->coded_width                                          = s->avctx->coded_width;
468 -    pic_param->coded_height                                         = s->avctx->coded_height;
469 -    pic_param->entrypoint_fields.value                              = 0; /* reset all bits */
470 -    pic_param->entrypoint_fields.bits.broken_link                   = v->broken_link;
471 -    pic_param->entrypoint_fields.bits.closed_entry                  = v->closed_entry;
472 -    pic_param->entrypoint_fields.bits.panscan_flag                  = v->panscanflag;
473 -    pic_param->entrypoint_fields.bits.loopfilter                    = s->loop_filter;
474 -    pic_param->conditional_overlap_flag                             = v->condover;
475 -    pic_param->fast_uvmc_flag                                       = v->fastuvmc;
476 -    pic_param->range_mapping_fields.value                           = 0; /* reset all bits */
477 -    pic_param->range_mapping_fields.bits.luma_flag                  = v->range_mapy_flag;
478 -    pic_param->range_mapping_fields.bits.luma                       = v->range_mapy;
479 -    pic_param->range_mapping_fields.bits.chroma_flag                = v->range_mapuv_flag;
480 -    pic_param->range_mapping_fields.bits.chroma                     = v->range_mapuv;
481 -    pic_param->b_picture_fraction                                   = v->bfraction_lut_index;
482 -    pic_param->cbp_table                                            = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0;
483 -    pic_param->mb_mode_table                                        = 0; /* XXX: interlaced frame */
484 -    pic_param->range_reduction_frame                                = v->rangeredfrm;
485 -    pic_param->rounding_control                                     = v->rnd;
486 -    pic_param->post_processing                                      = v->postproc;
487 -    pic_param->picture_resolution_index                             = v->respic;
488 -    pic_param->luma_scale                                           = v->lumscale;
489 -    pic_param->luma_shift                                           = v->lumshift;
490 -    pic_param->picture_fields.value                                 = 0; /* reset all bits */
491 -    pic_param->picture_fields.bits.picture_type                     = vc1_get_PTYPE(v);
492 -    pic_param->picture_fields.bits.frame_coding_mode                = v->fcm;
493 -    pic_param->picture_fields.bits.top_field_first                  = v->tff;
494 -    pic_param->picture_fields.bits.is_first_field                   = v->fcm == 0; /* XXX: interlaced frame */
495 -    pic_param->picture_fields.bits.intensity_compensation           = v->mv_mode == MV_PMODE_INTENSITY_COMP;
496 -    pic_param->raw_coding.value                                     = 0; /* reset all bits */
497 -    pic_param->raw_coding.flags.mv_type_mb                          = v->mv_type_is_raw;
498 -    pic_param->raw_coding.flags.direct_mb                           = v->dmb_is_raw;
499 -    pic_param->raw_coding.flags.skip_mb                             = v->skip_is_raw;
500 -    pic_param->raw_coding.flags.field_tx                            = 0; /* XXX: interlaced frame */
501 -    pic_param->raw_coding.flags.forward_mb                          = 0; /* XXX: interlaced frame */
502 -    pic_param->raw_coding.flags.ac_pred                             = v->acpred_is_raw;
503 -    pic_param->raw_coding.flags.overflags                           = v->overflg_is_raw;
504 -    pic_param->bitplane_present.value                               = 0; /* reset all bits */
505 -    pic_param->bitplane_present.flags.bp_mv_type_mb                 = vc1_has_MVTYPEMB_bitplane(v);
506 -    pic_param->bitplane_present.flags.bp_direct_mb                  = vc1_has_DIRECTMB_bitplane(v);
507 -    pic_param->bitplane_present.flags.bp_skip_mb                    = vc1_has_SKIPMB_bitplane(v);
508 -    pic_param->bitplane_present.flags.bp_field_tx                   = 0; /* XXX: interlaced frame */
509 -    pic_param->bitplane_present.flags.bp_forward_mb                 = 0; /* XXX: interlaced frame */
510 -    pic_param->bitplane_present.flags.bp_ac_pred                    = vc1_has_ACPRED_bitplane(v);
511 -    pic_param->bitplane_present.flags.bp_overflags                  = vc1_has_OVERFLAGS_bitplane(v);
512 -    pic_param->reference_fields.value                               = 0; /* reset all bits */
513 -    pic_param->reference_fields.bits.reference_distance_flag        = v->refdist_flag;
514 -    pic_param->reference_fields.bits.reference_distance             = 0; /* XXX: interlaced frame */
515 -    pic_param->reference_fields.bits.num_reference_pictures         = 0; /* XXX: interlaced frame */
516 -    pic_param->reference_fields.bits.reference_field_pic_indicator  = 0; /* XXX: interlaced frame */
517 -    pic_param->mv_fields.value                                      = 0; /* reset all bits */
518 -    pic_param->mv_fields.bits.mv_mode                               = vc1_get_MVMODE(v);
519 -    pic_param->mv_fields.bits.mv_mode2                              = vc1_get_MVMODE2(v);
520 -    pic_param->mv_fields.bits.mv_table                              = s->mv_table_index;
521 -    pic_param->mv_fields.bits.two_mv_block_pattern_table            = 0; /* XXX: interlaced frame */
522 -    pic_param->mv_fields.bits.four_mv_switch                        = 0; /* XXX: interlaced frame */
523 -    pic_param->mv_fields.bits.four_mv_block_pattern_table           = 0; /* XXX: interlaced frame */
524 -    pic_param->mv_fields.bits.extended_mv_flag                      = v->extended_mv;
525 -    pic_param->mv_fields.bits.extended_mv_range                     = v->mvrange;
526 -    pic_param->mv_fields.bits.extended_dmv_flag                     = v->extended_dmv;
527 -    pic_param->mv_fields.bits.extended_dmv_range                    = 0; /* XXX: interlaced frame */
528 -    pic_param->pic_quantizer_fields.value                           = 0; /* reset all bits */
529 -    pic_param->pic_quantizer_fields.bits.dquant                     = v->dquant;
530 -    pic_param->pic_quantizer_fields.bits.quantizer                  = v->quantizer_mode;
531 -    pic_param->pic_quantizer_fields.bits.half_qp                    = v->halfpq;
532 -    pic_param->pic_quantizer_fields.bits.pic_quantizer_scale        = v->pq;
533 -    pic_param->pic_quantizer_fields.bits.pic_quantizer_type         = v->pquantizer;
534 -    pic_param->pic_quantizer_fields.bits.dq_frame                   = v->dquantfrm;
535 -    pic_param->pic_quantizer_fields.bits.dq_profile                 = v->dqprofile;
536 -    pic_param->pic_quantizer_fields.bits.dq_sb_edge                 = v->dqprofile == DQPROFILE_SINGLE_EDGE  ? v->dqsbedge : 0;
537 -    pic_param->pic_quantizer_fields.bits.dq_db_edge                 = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0;
538 -    pic_param->pic_quantizer_fields.bits.dq_binary_level            = v->dqbilevel;
539 -    pic_param->pic_quantizer_fields.bits.alt_pic_quantizer          = v->altpq;
540 -    pic_param->transform_fields.value                               = 0; /* reset all bits */
541 -    pic_param->transform_fields.bits.variable_sized_transform_flag  = v->vstransform;
542 -    pic_param->transform_fields.bits.mb_level_transform_type_flag   = v->ttmbf;
543 -    pic_param->transform_fields.bits.frame_level_transform_type     = v->ttfrm;
544 -    pic_param->transform_fields.bits.transform_ac_codingset_idx1    = v->c_ac_table_index;
545 -    pic_param->transform_fields.bits.transform_ac_codingset_idx2    = v->y_ac_table_index;
546 -    pic_param->transform_fields.bits.intra_transform_dc_table       = v->s.dc_table_index;
547 +    pic_param->forward_reference_picture                                 = VA_INVALID_ID;
548 +    pic_param->backward_reference_picture                                = VA_INVALID_ID;
549 +    pic_param->inloop_decoded_picture                                    = VA_INVALID_ID;
550 +    pic_param->BFV(sequence_fields,value)                                = 0; /* reset all bits */
551 +    NEW(pic_param->BFM(sequence_fields,bits,pulldown)                    = v->broadcast);
552 +    pic_param->BFM(sequence_fields,bits,interlace)                       = v->interlace;
553 +    NEW(pic_param->BFM(sequence_fields,bits,tfcntrflag)                  = v->tfcntrflag);
554 +    NEW(pic_param->BFM(sequence_fields,bits,finterpflag)                 = v->finterpflag);
555 +    NEW(pic_param->BFM(sequence_fields,bits,psf)                         = v->psf);
556 +    NEW(pic_param->BFM(sequence_fields,bits,multires)                    = v->multires);
557 +    pic_param->BFM(sequence_fields,bits,overlap)                         = v->overlap;
558 +    pic_param->BFM(sequence_fields,bits,syncmarker)                      = s->resync_marker;
559 +    NEW(pic_param->BFM(sequence_fields,bits,rangered)                    = v->rangered);
560 +    NEW(pic_param->BFM(sequence_fields,bits,max_b_frames)                = s->avctx->max_b_frames);
561 +#if VA_CHECK_VERSION(0,32,0)
562 +    NEW(pic_param->BFM(sequence_fields,bits,profile)                     = v->profile);
563 +#endif
564 +    pic_param->coded_width                                               = s->avctx->coded_width;
565 +    pic_param->coded_height                                              = s->avctx->coded_height;
566 +    NEW(pic_param->BFV(entrypoint_fields,value)                          = 0); /* reset all bits */
567 +    pic_param->BFM(entrypoint_fields,bits,broken_link)                   = v->broken_link;
568 +    pic_param->BFM(entrypoint_fields,bits,closed_entry)                  = v->closed_entry;
569 +    NEW(pic_param->BFM(entrypoint_fields,bits,panscan_flag)              = v->panscanflag);
570 +    pic_param->BFM(entrypoint_fields,bits,loopfilter)                    = s->loop_filter;
571 +    pic_param->conditional_overlap_flag                                  = v->condover;
572 +    pic_param->fast_uvmc_flag                                            = v->fastuvmc;
573 +    pic_param->BFV(range_mapping_fields,value)                           = 0; /* reset all bits */
574 +    pic_param->BFMP(range_mapping,range_mapping_fields,bits,luma_flag)   = v->range_mapy_flag;
575 +    pic_param->BFMP(range_mapping,range_mapping_fields,bits,luma)        = v->range_mapy;
576 +    pic_param->BFMP(range_mapping,range_mapping_fields,bits,chroma_flag) = v->range_mapuv_flag;
577 +    pic_param->BFMP(range_mapping,range_mapping_fields,bits,chroma)      = v->range_mapuv;
578 +    pic_param->b_picture_fraction                                        = v->bfraction_lut_index;
579 +    pic_param->cbp_table                                                 = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0;
580 +    pic_param->mb_mode_table                                             = 0; /* XXX: interlaced frame */
581 +    pic_param->range_reduction_frame                                     = v->rangeredfrm;
582 +    pic_param->rounding_control                                          = v->rnd;
583 +    pic_param->post_processing                                           = v->postproc;
584 +    pic_param->picture_resolution_index                                  = v->respic;
585 +    pic_param->luma_scale                                                = v->lumscale;
586 +    pic_param->luma_shift                                                = v->lumshift;
587 +    pic_param->BFV(picture_fields,value)                                 = 0; /* reset all bits */
588 +    pic_param->BFM(picture_fields,bits,picture_type)                     = vc1_get_PTYPE(v);
589 +    pic_param->BFM(picture_fields,bits,frame_coding_mode)                = v->fcm;
590 +    pic_param->BFM(picture_fields,bits,top_field_first)                  = v->tff;
591 +    pic_param->BFM(picture_fields,bits,is_first_field)                   = v->fcm == 0; /* XXX: interlaced frame */
592 +    pic_param->BFM(picture_fields,bits,intensity_compensation)           = v->mv_mode == MV_PMODE_INTENSITY_COMP;
593 +    pic_param->BFV(V_raw_coding,value)                                   = 0; /* reset all bits */
594 +    pic_param->BFM(M_raw_coding,flags,mv_type_mb)                        = v->mv_type_is_raw;
595 +    pic_param->BFM(M_raw_coding,flags,direct_mb)                         = v->dmb_is_raw;
596 +    pic_param->BFM(M_raw_coding,flags,skip_mb)                           = v->skip_is_raw;
597 +    pic_param->BFM(M_raw_coding,flags,field_tx)                          = 0; /* XXX: interlaced frame */
598 +    pic_param->BFM(M_raw_coding,flags,forward_mb)                        = 0; /* XXX: interlaced frame */
599 +    pic_param->BFM(M_raw_coding,flags,ac_pred)                           = v->acpred_is_raw;
600 +    pic_param->BFM(M_raw_coding,flags,overflags)                         = v->overflg_is_raw;
601 +    pic_param->BFV(V_bitplane_present,value)                             = 0; /* reset all bits */
602 +    pic_param->BFM(M_bitplane_present,flags,bp_mv_type_mb)               = vc1_has_MVTYPEMB_bitplane(v);
603 +    pic_param->BFM(M_bitplane_present,flags,bp_direct_mb)                = vc1_has_DIRECTMB_bitplane(v);
604 +    pic_param->BFM(M_bitplane_present,flags,bp_skip_mb)                  = vc1_has_SKIPMB_bitplane(v);
605 +    pic_param->BFM(M_bitplane_present,flags,bp_field_tx)                 = 0; /* XXX: interlaced frame */
606 +    pic_param->BFM(M_bitplane_present,flags,bp_forward_mb)               = 0; /* XXX: interlaced frame */
607 +    pic_param->BFM(M_bitplane_present,flags,bp_ac_pred)                  = vc1_has_ACPRED_bitplane(v);
608 +    pic_param->BFM(M_bitplane_present,flags,bp_overflags)                = vc1_has_OVERFLAGS_bitplane(v);
609 +    pic_param->BFV(reference_fields,value)                               = 0; /* reset all bits */
610 +    pic_param->BFM(reference_fields,bits,reference_distance_flag)        = v->refdist_flag;
611 +    pic_param->BFM(reference_fields,bits,reference_distance)             = 0; /* XXX: interlaced frame */
612 +    pic_param->BFM(reference_fields,bits,num_reference_pictures)         = 0; /* XXX: interlaced frame */
613 +    pic_param->BFM(reference_fields,bits,reference_field_pic_indicator)  = 0; /* XXX: interlaced frame */
614 +    pic_param->BFV(mv_fields,value)                                      = 0; /* reset all bits */
615 +    pic_param->BFM(mv_fields,bits,mv_mode)                               = vc1_get_MVMODE(v);
616 +    pic_param->BFM(mv_fields,bits,mv_mode2)                              = vc1_get_MVMODE2(v);
617 +    pic_param->BFM(mv_fields,bits,mv_table)                              = s->mv_table_index;
618 +    pic_param->BFM(mv_fields,bits,two_mv_block_pattern_table)            = 0; /* XXX: interlaced frame */
619 +    pic_param->BFM(mv_fields,bits,four_mv_switch)                        = 0; /* XXX: interlaced frame */
620 +    pic_param->BFM(mv_fields,bits,four_mv_block_pattern_table)           = 0; /* XXX: interlaced frame */
621 +    pic_param->BFM(mv_fields,bits,extended_mv_flag)                      = v->extended_mv;
622 +    pic_param->BFM(mv_fields,bits,extended_mv_range)                     = v->mvrange;
623 +    pic_param->BFM(mv_fields,bits,extended_dmv_flag)                     = v->extended_dmv;
624 +    pic_param->BFM(mv_fields,bits,extended_dmv_range)                    = 0; /* XXX: interlaced frame */
625 +    pic_param->BFV(pic_quantizer_fields,value)                           = 0; /* reset all bits */
626 +    pic_param->BFM(pic_quantizer_fields,bits,dquant)                     = v->dquant;
627 +    pic_param->BFM(pic_quantizer_fields,bits,quantizer)                  = v->quantizer_mode;
628 +    pic_param->BFM(pic_quantizer_fields,bits,half_qp)                    = v->halfpq;
629 +    pic_param->BFM(pic_quantizer_fields,bits,pic_quantizer_scale)        = v->pq;
630 +    pic_param->BFM(pic_quantizer_fields,bits,pic_quantizer_type)         = v->pquantizer;
631 +    pic_param->BFM(pic_quantizer_fields,bits,dq_frame)                   = v->dquantfrm;
632 +    pic_param->BFM(pic_quantizer_fields,bits,dq_profile)                 = v->dqprofile;
633 +    pic_param->BFM(pic_quantizer_fields,bits,dq_sb_edge)                 = v->dqprofile == DQPROFILE_SINGLE_EDGE  ? v->dqsbedge : 0;
634 +    pic_param->BFM(pic_quantizer_fields,bits,dq_db_edge)                 = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0;
635 +    pic_param->BFM(pic_quantizer_fields,bits,dq_binary_level)            = v->dqbilevel;
636 +    pic_param->BFM(pic_quantizer_fields,bits,alt_pic_quantizer)          = v->altpq;
637 +    pic_param->BFV(transform_fields,value)                               = 0; /* reset all bits */
638 +    pic_param->BFM(transform_fields,bits,variable_sized_transform_flag)  = v->vstransform;
639 +    pic_param->BFM(transform_fields,bits,mb_level_transform_type_flag)   = v->ttmbf;
640 +    pic_param->BFM(transform_fields,bits,frame_level_transform_type)     = v->ttfrm;
641 +    pic_param->BFM(transform_fields,bits,transform_ac_codingset_idx1)    = v->c_ac_table_index;
642 +    pic_param->BFM(transform_fields,bits,transform_ac_codingset_idx2)    = v->y_ac_table_index;
643 +    pic_param->BFM(transform_fields,bits,intra_transform_dc_table)       = v->s.dc_table_index;
644  
645      switch (s->pict_type) {
646      case FF_B_TYPE:
647 @@ -251,29 +253,29 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t
648          break;
649      }
650  
651 -    if (pic_param->bitplane_present.value) {
652 +    if (pic_param->BFV(V_bitplane_present,value)) {
653          uint8_t *bitplane;
654          const uint8_t *ff_bp[3];
655          int x, y, n;
656  
657          switch (s->pict_type) {
658          case FF_P_TYPE:
659 -            ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb  ? v->direct_mb_plane    : NULL;
660 -            ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb    ? s->mbskip_table       : NULL;
661 -            ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane   : NULL;
662 +            ff_bp[0] = pic_param->BFM(M_bitplane_present,flags,bp_direct_mb)  ? v->direct_mb_plane    : NULL;
663 +            ff_bp[1] = pic_param->BFM(M_bitplane_present,flags,bp_skip_mb)    ? s->mbskip_table       : NULL;
664 +            ff_bp[2] = pic_param->BFM(M_bitplane_present,flags,bp_mv_type_mb) ? v->mv_type_mb_plane   : NULL;
665              break;
666          case FF_B_TYPE:
667              if (!v->bi_type) {
668 -                ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
669 -                ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb   ? s->mbskip_table    : NULL;
670 +                ff_bp[0] = pic_param->BFM(M_bitplane_present,flags,bp_direct_mb) ? v->direct_mb_plane : NULL;
671 +                ff_bp[1] = pic_param->BFM(M_bitplane_present,flags,bp_skip_mb)   ? s->mbskip_table    : NULL;
672                  ff_bp[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */
673                  break;
674              }
675              /* fall-through (BI-type) */
676          case FF_I_TYPE:
677              ff_bp[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */
678 -            ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred    ? v->acpred_plane       : NULL;
679 -            ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags  ? v->over_flags_plane   : NULL;
680 +            ff_bp[1] = pic_param->BFM(M_bitplane_present,flags,bp_ac_pred)    ? v->acpred_plane       : NULL;
681 +            ff_bp[2] = pic_param->BFM(M_bitplane_present,flags,bp_overflags)  ? v->over_flags_plane   : NULL;
682              break;
683          default:
684              ff_bp[0] = NULL;
685 diff --git a/libvo/vo_vaapi.c b/libvo/vo_vaapi.c
686 index 9d46485..1ab47b3 100644
687 --- a/libvo/vo_vaapi.c
688 +++ b/libvo/vo_vaapi.c
689 @@ -45,7 +45,11 @@
690  #include <assert.h>
691  #include <X11/Xlib.h>
692  #include <X11/Xutil.h>
693 +#if CONFIG_VAAPI_OLD
694 +#include <va_x11.h>
695 +#else
696  #include <va/va_x11.h>
697 +#endif
698  #if CONFIG_VAAPI_GLX
699  #include <va/va_glx.h>
700  #endif
701 -- 
702 1.5.4.3
703