Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
changelog: misc typo and wording fixes
H.264: add filter_mb_fast support for >8-bit decoding
doc: Remove outdated comments about gcc 2.95 and gcc 3.3 support.
lls: use av_lfg instead of rand() in test program
build: remove unnecessary dependency on libs from 'all' target
H.264: avoid redundant alpha/beta calculations in loopfilter
H.264: optimize intra/inter loopfilter decision
mpegts: fix Continuity Counter error detection
build: remove unnecessary FFLDFLAGS variable
vp8/mt: flush worker thread, not application thread context, on seek.
mt: proper locking around release_buffer calls.
DxVA2: unbreak build after [657ccb5ac75ce34e62bd67f228d9bd36db72189e]
hwaccel: unbreak build
Eliminate FF_COMMON_FRAME macro.

Conflicts:
Changelog
Makefile
doc/developer.texi
libavcodec/avcodec.h
libavcodec/h264.c
libavcodec/mpeg4videodec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/07/12 08:42:32
Showing 59 changed files
... ...
@@ -8,6 +8,7 @@ version next:
8 8
 
9 9
 version 0.8:
10 10
 
11
+
11 12
 - many many things we forgot because we rather write code than changelogs
12 13
 - WebM support in Matroska de/muxer
13 14
 - low overhead Ogg muxing
... ...
@@ -57,10 +58,10 @@ version 0.8:
57 57
 - demuxer for receiving raw rtp:// URLs without an SDP description
58 58
 - single stream LATM/LOAS decoder
59 59
 - setpts filter added
60
-- Win64 support for optimized asm functions
60
+- Win64 support for optimized x86 assembly functions
61 61
 - MJPEG/AVI1 to JPEG/JFIF bitstream filter
62 62
 - ASS subtitle encoder and decoder
63
-- IEC 61937 encapsulation for E-AC3, TrueHD, DTS-HD (for HDMI passthrough)
63
+- IEC 61937 encapsulation for E-AC-3, TrueHD, DTS-HD (for HDMI passthrough)
64 64
 - overlay filter added
65 65
 - rename aspect filter to setdar, and pixelaspect to setsar
66 66
 - IEC 61937 demuxer
... ...
@@ -8,6 +8,7 @@ vpath %.asm  $(SRC_PATH)
8 8
 vpath %.v    $(SRC_PATH)
9 9
 vpath %.texi $(SRC_PATH)
10 10
 
11
+
11 12
 PROGS-$(CONFIG_FFMPEG)   += ffmpeg
12 13
 PROGS-$(CONFIG_FFPLAY)   += ffplay
13 14
 PROGS-$(CONFIG_FFPROBE)  += ffprobe
... ...
@@ -43,11 +44,10 @@ SKIPHEADERS = cmdutils_common_opts.h
43 43
 
44 44
 include $(SRC_PATH)/common.mak
45 45
 
46
-FF_LDFLAGS   := $(FFLDFLAGS)
47 46
 FF_EXTRALIBS := $(FFEXTRALIBS)
48 47
 FF_DEP_LIBS  := $(DEP_LIBS)
49 48
 
50
-all: $(FF_DEP_LIBS) $(PROGS)
49
+all: $(PROGS)
51 50
 
52 51
 $(PROGS): %$(EXESUF): %_g$(EXESUF)
53 52
 	$(CP) $< $@
... ...
@@ -83,10 +83,10 @@ $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
83 83
 
84 84
 ffplay.o: CFLAGS += $(SDL_CFLAGS)
85 85
 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
86
-ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
86
+ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
87 87
 
88 88
 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
89
-	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
89
+	$(LD) $(LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
90 90
 
91 91
 OBJDIRS += tools
92 92
 
... ...
@@ -27,6 +27,7 @@ CFLAGS     += $(ECFLAGS)
27 27
 CCFLAGS     = $(CFLAGS)
28 28
 YASMFLAGS  += $(IFLAGS) -Pconfig.asm
29 29
 HOSTCFLAGS += $(IFLAGS)
30
+LDFLAGS    += $(ALLFFLIBS:%=-Llib%)
30 31
 
31 32
 define COMPILE
32 33
        $($(1)DEP)
... ...
@@ -69,7 +70,6 @@ FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
69 69
 TESTPROGS += $(TESTPROGS-yes)
70 70
 
71 71
 FFEXTRALIBS := $(FFLIBS:%=-l%$(BUILDSUF)) $(EXTRALIBS)
72
-FFLDFLAGS   := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS)
73 72
 
74 73
 EXAMPLES  := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
75 74
 OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
... ...
@@ -54,10 +54,8 @@ These features are supported by all compilers we care about, so we will not
54 54
 accept patches to remove their use unless they absolutely do not impair
55 55
 clarity and performance.
56 56
 
57
-All code must compile with GCC 3.3. Currently, FFmpeg also
58
-compiles with several other compilers, such as the Compaq ccc compiler
59
-or Sun Studio 9, and we would like to keep it that way unless it would
60
-be exceedingly involved. To ensure compatibility, please do not use any
57
+All code must compile with recent versions of GCC and a number of other
58
+currently supported compilers. To ensure compatibility, please do not use
61 59
 additional C99 features or GCC extensions. Especially watch out for:
62 60
 @itemize @bullet
63 61
 @item
... ...
@@ -750,304 +750,6 @@ typedef struct AVPanScan{
750 750
     int16_t position[3][2];
751 751
 }AVPanScan;
752 752
 
753
-#define FF_COMMON_FRAME \
754
-    /**\
755
-     * pointer to the picture planes.\
756
-     * This might be different from the first allocated byte\
757
-     * - encoding: \
758
-     * - decoding: \
759
-     */\
760
-    uint8_t *data[4];\
761
-    int linesize[4];\
762
-    /**\
763
-     * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
764
-     * This isn't used by libavcodec unless the default get/release_buffer() is used.\
765
-     * - encoding: \
766
-     * - decoding: \
767
-     */\
768
-    uint8_t *base[4];\
769
-    /**\
770
-     * 1 -> keyframe, 0-> not\
771
-     * - encoding: Set by libavcodec.\
772
-     * - decoding: Set by libavcodec.\
773
-     */\
774
-    int key_frame;\
775
-\
776
-    /**\
777
-     * Picture type of the frame, see ?_TYPE below.\
778
-     * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
779
-     * - decoding: Set by libavcodec.\
780
-     */\
781
-    enum AVPictureType pict_type;\
782
-\
783
-    /**\
784
-     * presentation timestamp in time_base units (time when frame should be shown to user)\
785
-     * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\
786
-     * - encoding: MUST be set by user.\
787
-     * - decoding: Set by libavcodec.\
788
-     */\
789
-    int64_t pts;\
790
-\
791
-    /**\
792
-     * picture number in bitstream order\
793
-     * - encoding: set by\
794
-     * - decoding: Set by libavcodec.\
795
-     */\
796
-    int coded_picture_number;\
797
-    /**\
798
-     * picture number in display order\
799
-     * - encoding: set by\
800
-     * - decoding: Set by libavcodec.\
801
-     */\
802
-    int display_picture_number;\
803
-\
804
-    /**\
805
-     * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
806
-     * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
807
-     * - decoding: Set by libavcodec.\
808
-     */\
809
-    int quality; \
810
-\
811
-    /**\
812
-     * buffer age (1->was last buffer and dint change, 2->..., ...).\
813
-     * Set to INT_MAX if the buffer has not been used yet.\
814
-     * - encoding: unused\
815
-     * - decoding: MUST be set by get_buffer().\
816
-     */\
817
-    int age;\
818
-\
819
-    /**\
820
-     * is this picture used as reference\
821
-     * The values for this are the same as the MpegEncContext.picture_structure\
822
-     * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\
823
-     * Set to 4 for delayed, non-reference frames.\
824
-     * - encoding: unused\
825
-     * - decoding: Set by libavcodec. (before get_buffer() call)).\
826
-     */\
827
-    int reference;\
828
-\
829
-    /**\
830
-     * QP table\
831
-     * - encoding: unused\
832
-     * - decoding: Set by libavcodec.\
833
-     */\
834
-    int8_t *qscale_table;\
835
-    /**\
836
-     * QP store stride\
837
-     * - encoding: unused\
838
-     * - decoding: Set by libavcodec.\
839
-     */\
840
-    int qstride;\
841
-\
842
-    /**\
843
-     * mbskip_table[mb]>=1 if MB didn't change\
844
-     * stride= mb_width = (width+15)>>4\
845
-     * - encoding: unused\
846
-     * - decoding: Set by libavcodec.\
847
-     */\
848
-    uint8_t *mbskip_table;\
849
-\
850
-    /**\
851
-     * motion vector table\
852
-     * @code\
853
-     * example:\
854
-     * int mv_sample_log2= 4 - motion_subsample_log2;\
855
-     * int mb_width= (width+15)>>4;\
856
-     * int mv_stride= (mb_width << mv_sample_log2) + 1;\
857
-     * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
858
-     * @endcode\
859
-     * - encoding: Set by user.\
860
-     * - decoding: Set by libavcodec.\
861
-     */\
862
-    int16_t (*motion_val[2])[2];\
863
-\
864
-    /**\
865
-     * macroblock type table\
866
-     * mb_type_base + mb_width + 2\
867
-     * - encoding: Set by user.\
868
-     * - decoding: Set by libavcodec.\
869
-     */\
870
-    uint32_t *mb_type;\
871
-\
872
-    /**\
873
-     * log2 of the size of the block which a single vector in motion_val represents: \
874
-     * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
875
-     * - encoding: unused\
876
-     * - decoding: Set by libavcodec.\
877
-     */\
878
-    uint8_t motion_subsample_log2;\
879
-\
880
-    /**\
881
-     * for some private data of the user\
882
-     * - encoding: unused\
883
-     * - decoding: Set by user.\
884
-     */\
885
-    void *opaque;\
886
-\
887
-    /**\
888
-     * error\
889
-     * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\
890
-     * - decoding: unused\
891
-     */\
892
-    uint64_t error[4];\
893
-\
894
-    /**\
895
-     * type of the buffer (to keep track of who has to deallocate data[*])\
896
-     * - encoding: Set by the one who allocates it.\
897
-     * - decoding: Set by the one who allocates it.\
898
-     * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\
899
-     */\
900
-    int type;\
901
-    \
902
-    /**\
903
-     * When decoding, this signals how much the picture must be delayed.\
904
-     * extra_delay = repeat_pict / (2*fps)\
905
-     * - encoding: unused\
906
-     * - decoding: Set by libavcodec.\
907
-     */\
908
-    int repeat_pict;\
909
-    \
910
-    /**\
911
-     * \
912
-     */\
913
-    int qscale_type;\
914
-    \
915
-    /**\
916
-     * The content of the picture is interlaced.\
917
-     * - encoding: Set by user.\
918
-     * - decoding: Set by libavcodec. (default 0)\
919
-     */\
920
-    int interlaced_frame;\
921
-    \
922
-    /**\
923
-     * If the content is interlaced, is top field displayed first.\
924
-     * - encoding: Set by user.\
925
-     * - decoding: Set by libavcodec.\
926
-     */\
927
-    int top_field_first;\
928
-    \
929
-    /**\
930
-     * Pan scan.\
931
-     * - encoding: Set by user.\
932
-     * - decoding: Set by libavcodec.\
933
-     */\
934
-    AVPanScan *pan_scan;\
935
-    \
936
-    /**\
937
-     * Tell user application that palette has changed from previous frame.\
938
-     * - encoding: ??? (no palette-enabled encoder yet)\
939
-     * - decoding: Set by libavcodec. (default 0).\
940
-     */\
941
-    int palette_has_changed;\
942
-    \
943
-    /**\
944
-     * codec suggestion on buffer type if != 0\
945
-     * - encoding: unused\
946
-     * - decoding: Set by libavcodec. (before get_buffer() call)).\
947
-     */\
948
-    int buffer_hints;\
949
-\
950
-    /**\
951
-     * DCT coefficients\
952
-     * - encoding: unused\
953
-     * - decoding: Set by libavcodec.\
954
-     */\
955
-    short *dct_coeff;\
956
-\
957
-    /**\
958
-     * motion reference frame index\
959
-     * the order in which these are stored can depend on the codec.\
960
-     * - encoding: Set by user.\
961
-     * - decoding: Set by libavcodec.\
962
-     */\
963
-    int8_t *ref_index[2];\
964
-\
965
-    /**\
966
-     * reordered opaque 64bit (generally an integer or a double precision float\
967
-     * PTS but can be anything). \
968
-     * The user sets AVCodecContext.reordered_opaque to represent the input at\
969
-     * that time,\
970
-     * the decoder reorders values as needed and sets AVFrame.reordered_opaque\
971
-     * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque \
972
-     * @deprecated in favor of pkt_pts\
973
-     * - encoding: unused\
974
-     * - decoding: Read by user.\
975
-     */\
976
-    int64_t reordered_opaque;\
977
-\
978
-    /**\
979
-     * hardware accelerator private data (FFmpeg allocated)\
980
-     * - encoding: unused\
981
-     * - decoding: Set by libavcodec\
982
-     */\
983
-    void *hwaccel_picture_private;\
984
-\
985
-    /**\
986
-     * reordered pts from the last AVPacket that has been input into the decoder\
987
-     * - encoding: unused\
988
-     * - decoding: Read by user.\
989
-     */\
990
-    int64_t pkt_pts;\
991
-\
992
-    /**\
993
-     * dts from the last AVPacket that has been input into the decoder\
994
-     * - encoding: unused\
995
-     * - decoding: Read by user.\
996
-     */\
997
-    int64_t pkt_dts;\
998
-\
999
-    /**\
1000
-     * the AVCodecContext which ff_thread_get_buffer() was last called on\
1001
-     * - encoding: Set by libavcodec.\
1002
-     * - decoding: Set by libavcodec.\
1003
-     */\
1004
-    struct AVCodecContext *owner;\
1005
-\
1006
-    /**\
1007
-     * used by multithreading to store frame-specific info\
1008
-     * - encoding: Set by libavcodec.\
1009
-     * - decoding: Set by libavcodec.\
1010
-     */\
1011
-    void *thread_opaque;\
1012
-\
1013
-    /**\
1014
-     * frame timestamp estimated using various heuristics, in stream time base\
1015
-     * - encoding: unused\
1016
-     * - decoding: set by libavcodec, read by user.\
1017
-     */\
1018
-    int64_t best_effort_timestamp;\
1019
-\
1020
-    /**\
1021
-     * reordered pos from the last AVPacket that has been input into the decoder\
1022
-     * - encoding: unused\
1023
-     * - decoding: Read by user.\
1024
-     */\
1025
-    int64_t pkt_pos;\
1026
-\
1027
-    /**\
1028
-     * reordered sample aspect ratio for the video frame, 0/1 if unknown\unspecified
1029
-     * - encoding: unused\
1030
-     * - decoding: Read by user.\
1031
-     */\
1032
-    AVRational sample_aspect_ratio;\
1033
-\
1034
-    /**\
1035
-     * width and height of the video frame\
1036
-     * - encoding: unused\
1037
-     * - decoding: Read by user.\
1038
-     */\
1039
-    int width, height;\
1040
-\
1041
-    /**\
1042
-     * format of the frame, -1 if unknown or unset\
1043
-     * It should be cast to the corresponding enum (enum PixelFormat\
1044
-     * for video, enum AVSampleFormat for audio)\
1045
-     * - encoding: unused\
1046
-     * - decoding: Read by user.\
1047
-     */\
1048
-    int format;\
1049
-
1050
-
1051 753
 #define FF_QSCALE_TYPE_MPEG1 0
1052 754
 #define FF_QSCALE_TYPE_MPEG2 1
1053 755
 #define FF_QSCALE_TYPE_H264  2
... ...
@@ -1142,15 +844,308 @@ typedef struct AVPacket {
1142 1142
 
1143 1143
 /**
1144 1144
  * Audio Video Frame.
1145
- * New fields can be added to the end of FF_COMMON_FRAME with minor version
1146
- * bumps.
1147
- * Removal, reordering and changes to existing fields require a major
1148
- * version bump. No fields should be added into AVFrame before or after
1149
- * FF_COMMON_FRAME!
1145
+ * New fields can be added to the end of AVFRAME with minor version
1146
+ * bumps. Removal, reordering and changes to existing fields require
1147
+ * a major version bump.
1150 1148
  * sizeof(AVFrame) must not be used outside libav*.
1151 1149
  */
1152 1150
 typedef struct AVFrame {
1153
-    FF_COMMON_FRAME
1151
+    /**
1152
+     * pointer to the picture planes.
1153
+     * This might be different from the first allocated byte
1154
+     * - encoding:
1155
+     * - decoding:
1156
+     */
1157
+    uint8_t *data[4];
1158
+    int linesize[4];
1159
+    /**
1160
+     * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
1161
+     * This isn't used by libavcodec unless the default get/release_buffer() is used.
1162
+     * - encoding:
1163
+     * - decoding:
1164
+     */
1165
+    uint8_t *base[4];
1166
+    /**
1167
+     * 1 -> keyframe, 0-> not
1168
+     * - encoding: Set by libavcodec.
1169
+     * - decoding: Set by libavcodec.
1170
+     */
1171
+    int key_frame;
1172
+
1173
+    /**
1174
+     * Picture type of the frame, see ?_TYPE below.
1175
+     * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1176
+     * - decoding: Set by libavcodec.
1177
+     */
1178
+    enum AVPictureType pict_type;
1179
+
1180
+    /**
1181
+     * presentation timestamp in time_base units (time when frame should be shown to user)
1182
+     * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
1183
+     * - encoding: MUST be set by user.
1184
+     * - decoding: Set by libavcodec.
1185
+     */
1186
+    int64_t pts;
1187
+
1188
+    /**
1189
+     * picture number in bitstream order
1190
+     * - encoding: set by
1191
+     * - decoding: Set by libavcodec.
1192
+     */
1193
+    int coded_picture_number;
1194
+    /**
1195
+     * picture number in display order
1196
+     * - encoding: set by
1197
+     * - decoding: Set by libavcodec.
1198
+     */
1199
+    int display_picture_number;
1200
+
1201
+    /**
1202
+     * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
1203
+     * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1204
+     * - decoding: Set by libavcodec.
1205
+     */
1206
+    int quality;
1207
+
1208
+    /**
1209
+     * buffer age (1->was last buffer and dint change, 2->..., ...).
1210
+     * Set to INT_MAX if the buffer has not been used yet.
1211
+     * - encoding: unused
1212
+     * - decoding: MUST be set by get_buffer().
1213
+     */
1214
+    int age;
1215
+
1216
+    /**
1217
+     * is this picture used as reference
1218
+     * The values for this are the same as the MpegEncContext.picture_structure
1219
+     * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
1220
+     * Set to 4 for delayed, non-reference frames.
1221
+     * - encoding: unused
1222
+     * - decoding: Set by libavcodec. (before get_buffer() call)).
1223
+     */
1224
+    int reference;
1225
+
1226
+    /**
1227
+     * QP table
1228
+     * - encoding: unused
1229
+     * - decoding: Set by libavcodec.
1230
+     */
1231
+    int8_t *qscale_table;
1232
+    /**
1233
+     * QP store stride
1234
+     * - encoding: unused
1235
+     * - decoding: Set by libavcodec.
1236
+     */
1237
+    int qstride;
1238
+
1239
+    /**
1240
+     * mbskip_table[mb]>=1 if MB didn't change
1241
+     * stride= mb_width = (width+15)>>4
1242
+     * - encoding: unused
1243
+     * - decoding: Set by libavcodec.
1244
+     */
1245
+    uint8_t *mbskip_table;
1246
+
1247
+    /**
1248
+     * motion vector table
1249
+     * @code
1250
+     * example:
1251
+     * int mv_sample_log2= 4 - motion_subsample_log2;
1252
+     * int mb_width= (width+15)>>4;
1253
+     * int mv_stride= (mb_width << mv_sample_log2) + 1;
1254
+     * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
1255
+     * @endcode
1256
+     * - encoding: Set by user.
1257
+     * - decoding: Set by libavcodec.
1258
+     */
1259
+    int16_t (*motion_val[2])[2];
1260
+
1261
+    /**
1262
+     * macroblock type table
1263
+     * mb_type_base + mb_width + 2
1264
+     * - encoding: Set by user.
1265
+     * - decoding: Set by libavcodec.
1266
+     */
1267
+    uint32_t *mb_type;
1268
+
1269
+    /**
1270
+     * log2 of the size of the block which a single vector in motion_val represents:
1271
+     * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
1272
+     * - encoding: unused
1273
+     * - decoding: Set by libavcodec.
1274
+     */
1275
+    uint8_t motion_subsample_log2;
1276
+
1277
+    /**
1278
+     * for some private data of the user
1279
+     * - encoding: unused
1280
+     * - decoding: Set by user.
1281
+     */
1282
+    void *opaque;
1283
+
1284
+    /**
1285
+     * error
1286
+     * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1287
+     * - decoding: unused
1288
+     */
1289
+    uint64_t error[4];
1290
+
1291
+    /**
1292
+     * type of the buffer (to keep track of who has to deallocate data[*])
1293
+     * - encoding: Set by the one who allocates it.
1294
+     * - decoding: Set by the one who allocates it.
1295
+     * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
1296
+     */
1297
+    int type;
1298
+
1299
+    /**
1300
+     * When decoding, this signals how much the picture must be delayed.
1301
+     * extra_delay = repeat_pict / (2*fps)
1302
+     * - encoding: unused
1303
+     * - decoding: Set by libavcodec.
1304
+     */
1305
+    int repeat_pict;
1306
+
1307
+    /**
1308
+     *
1309
+     */
1310
+    int qscale_type;
1311
+
1312
+    /**
1313
+     * The content of the picture is interlaced.
1314
+     * - encoding: Set by user.
1315
+     * - decoding: Set by libavcodec. (default 0)
1316
+     */
1317
+    int interlaced_frame;
1318
+
1319
+    /**
1320
+     * If the content is interlaced, is top field displayed first.
1321
+     * - encoding: Set by user.
1322
+     * - decoding: Set by libavcodec.
1323
+     */
1324
+    int top_field_first;
1325
+
1326
+    /**
1327
+     * Pan scan.
1328
+     * - encoding: Set by user.
1329
+     * - decoding: Set by libavcodec.
1330
+     */
1331
+    AVPanScan *pan_scan;
1332
+
1333
+    /**
1334
+     * Tell user application that palette has changed from previous frame.
1335
+     * - encoding: ??? (no palette-enabled encoder yet)
1336
+     * - decoding: Set by libavcodec. (default 0).
1337
+     */
1338
+    int palette_has_changed;
1339
+
1340
+    /**
1341
+     * codec suggestion on buffer type if != 0
1342
+     * - encoding: unused
1343
+     * - decoding: Set by libavcodec. (before get_buffer() call)).
1344
+     */
1345
+    int buffer_hints;
1346
+
1347
+    /**
1348
+     * DCT coefficients
1349
+     * - encoding: unused
1350
+     * - decoding: Set by libavcodec.
1351
+     */
1352
+    short *dct_coeff;
1353
+
1354
+    /**
1355
+     * motion reference frame index
1356
+     * the order in which these are stored can depend on the codec.
1357
+     * - encoding: Set by user.
1358
+     * - decoding: Set by libavcodec.
1359
+     */
1360
+    int8_t *ref_index[2];
1361
+
1362
+    /**
1363
+     * reordered opaque 64bit (generally an integer or a double precision float
1364
+     * PTS but can be anything).
1365
+     * The user sets AVCodecContext.reordered_opaque to represent the input at
1366
+     * that time,
1367
+     * the decoder reorders values as needed and sets AVFrame.reordered_opaque
1368
+     * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
1369
+     * @deprecated in favor of pkt_pts
1370
+     * - encoding: unused
1371
+     * - decoding: Read by user.
1372
+     */
1373
+    int64_t reordered_opaque;
1374
+
1375
+    /**
1376
+     * hardware accelerator private data (FFmpeg-allocated)
1377
+     * - encoding: unused
1378
+     * - decoding: Set by libavcodec
1379
+     */
1380
+    void *hwaccel_picture_private;
1381
+
1382
+    /**
1383
+     * reordered pts from the last AVPacket that has been input into the decoder
1384
+     * - encoding: unused
1385
+     * - decoding: Read by user.
1386
+     */
1387
+    int64_t pkt_pts;
1388
+
1389
+    /**
1390
+     * dts from the last AVPacket that has been input into the decoder
1391
+     * - encoding: unused
1392
+     * - decoding: Read by user.
1393
+     */
1394
+    int64_t pkt_dts;
1395
+
1396
+    /**
1397
+     * the AVCodecContext which ff_thread_get_buffer() was last called on
1398
+     * - encoding: Set by libavcodec.
1399
+     * - decoding: Set by libavcodec.
1400
+     */
1401
+    struct AVCodecContext *owner;
1402
+
1403
+    /**
1404
+     * used by multithreading to store frame-specific info
1405
+     * - encoding: Set by libavcodec.
1406
+     * - decoding: Set by libavcodec.
1407
+     */
1408
+    void *thread_opaque;
1409
+
1410
+    /**
1411
+     * frame timestamp estimated using various heuristics, in stream time base
1412
+     * - encoding: unused
1413
+     * - decoding: set by libavcodec, read by user.
1414
+     */
1415
+    int64_t best_effort_timestamp;
1416
+
1417
+    /**
1418
+     * reordered pos from the last AVPacket that has been input into the decoder
1419
+     * - encoding: unused
1420
+     * - decoding: Read by user.
1421
+     */
1422
+    int64_t pkt_pos;
1423
+
1424
+    /**
1425
+     * reordered sample aspect ratio for the video frame, 0/1 if unknown\unspecified
1426
+     * - encoding: unused
1427
+     * - decoding: Read by user.
1428
+     */
1429
+    AVRational sample_aspect_ratio;
1430
+
1431
+    /**
1432
+     * width and height of the video frame
1433
+     * - encoding: unused
1434
+     * - decoding: Read by user.
1435
+     */
1436
+    int width, height;
1437
+
1438
+    /**
1439
+     * format of the frame, -1 if unknown or unset
1440
+     * It should be cast to the corresponding enum (enum PixelFormat
1441
+     * for video, enum AVSampleFormat for audio)
1442
+     * - encoding: unused
1443
+     * - decoding: Read by user.
1444
+     */
1445
+    int format;
1446
+
1154 1447
 } AVFrame;
1155 1448
 
1156 1449
 /**
... ...
@@ -333,9 +333,9 @@ static inline void mc_dir_part(AVSContext *h,Picture *pic,int square,
333 333
     const int mx= mv->x + src_x_offset*8;
334 334
     const int my= mv->y + src_y_offset*8;
335 335
     const int luma_xy= (mx&3) + ((my&3)<<2);
336
-    uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*h->l_stride;
337
-    uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*h->c_stride;
338
-    uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*h->c_stride;
336
+    uint8_t * src_y  = pic->f.data[0] + (mx >> 2) + (my >> 2) * h->l_stride;
337
+    uint8_t * src_cb = pic->f.data[1] + (mx >> 3) + (my >> 3) * h->c_stride;
338
+    uint8_t * src_cr = pic->f.data[2] + (mx >> 3) + (my >> 3) * h->c_stride;
339 339
     int extra_width= 0; //(s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16;
340 340
     int extra_height= extra_width;
341 341
     int emu=0;
... ...
@@ -344,7 +344,7 @@ static inline void mc_dir_part(AVSContext *h,Picture *pic,int square,
344 344
     const int pic_width  = 16*h->mb_width;
345 345
     const int pic_height = 16*h->mb_height;
346 346
 
347
-    if(!pic->data[0])
347
+    if(!pic->f.data[0])
348 348
         return;
349 349
     if(mx&7) extra_width -= 3;
350 350
     if(my&7) extra_height -= 3;
... ...
@@ -602,9 +602,9 @@ int ff_cavs_next_mb(AVSContext *h) {
602 602
         h->mbx = 0;
603 603
         h->mby++;
604 604
         /* re-calculate sample pointers */
605
-        h->cy = h->picture.data[0] + h->mby*16*h->l_stride;
606
-        h->cu = h->picture.data[1] + h->mby*8*h->c_stride;
607
-        h->cv = h->picture.data[2] + h->mby*8*h->c_stride;
605
+        h->cy = h->picture.f.data[0] + h->mby * 16 * h->l_stride;
606
+        h->cu = h->picture.f.data[1] + h->mby *  8 * h->c_stride;
607
+        h->cv = h->picture.f.data[2] + h->mby *  8 * h->c_stride;
608 608
         if(h->mby == h->mb_height) { //frame end
609 609
             return 0;
610 610
         }
... ...
@@ -629,11 +629,11 @@ void ff_cavs_init_pic(AVSContext *h) {
629 629
     h->mv[MV_FWD_X0] = ff_cavs_dir_mv;
630 630
     set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
631 631
     h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
632
-    h->cy = h->picture.data[0];
633
-    h->cu = h->picture.data[1];
634
-    h->cv = h->picture.data[2];
635
-    h->l_stride = h->picture.linesize[0];
636
-    h->c_stride = h->picture.linesize[1];
632
+    h->cy           = h->picture.f.data[0];
633
+    h->cu           = h->picture.f.data[1];
634
+    h->cv           = h->picture.f.data[2];
635
+    h->l_stride     = h->picture.f.linesize[0];
636
+    h->c_stride     = h->picture.f.linesize[1];
637 637
     h->luma_scan[2] = 8*h->l_stride;
638 638
     h->luma_scan[3] = 8*h->l_stride+8;
639 639
     h->mbx = h->mby = h->mbidx = 0;
... ...
@@ -476,8 +476,8 @@ static int decode_pic(AVSContext *h) {
476 476
             return -1;
477 477
         }
478 478
         /* make sure we have the reference frames we need */
479
-        if(!h->DPB[0].data[0] ||
480
-          (!h->DPB[1].data[0] && h->pic_type == AV_PICTURE_TYPE_B))
479
+        if(!h->DPB[0].f.data[0] ||
480
+          (!h->DPB[1].f.data[0] && h->pic_type == AV_PICTURE_TYPE_B))
481 481
             return -1;
482 482
     } else {
483 483
         h->pic_type = AV_PICTURE_TYPE_I;
... ...
@@ -494,7 +494,7 @@ static int decode_pic(AVSContext *h) {
494 494
             skip_bits(&s->gb,1); //marker_bit
495 495
     }
496 496
     /* release last B frame */
497
-    if(h->picture.data[0])
497
+    if(h->picture.f.data[0])
498 498
         s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture);
499 499
 
500 500
     s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture);
... ...
@@ -585,7 +585,7 @@ static int decode_pic(AVSContext *h) {
585 585
         } while(ff_cavs_next_mb(h));
586 586
     }
587 587
     if(h->pic_type != AV_PICTURE_TYPE_B) {
588
-        if(h->DPB[1].data[0])
588
+        if(h->DPB[1].f.data[0])
589 589
             s->avctx->release_buffer(s->avctx, (AVFrame *)&h->DPB[1]);
590 590
         h->DPB[1] = h->DPB[0];
591 591
         h->DPB[0] = h->picture;
... ...
@@ -648,7 +648,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
648 648
     s->avctx = avctx;
649 649
 
650 650
     if (buf_size == 0) {
651
-        if(!s->low_delay && h->DPB[0].data[0]) {
651
+        if (!s->low_delay && h->DPB[0].f.data[0]) {
652 652
             *data_size = sizeof(AVPicture);
653 653
             *picture = *(AVFrame *) &h->DPB[0];
654 654
         }
... ...
@@ -669,9 +669,9 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
669 669
             break;
670 670
         case PIC_I_START_CODE:
671 671
             if(!h->got_keyframe) {
672
-                if(h->DPB[0].data[0])
672
+                if(h->DPB[0].f.data[0])
673 673
                     avctx->release_buffer(avctx, (AVFrame *)&h->DPB[0]);
674
-                if(h->DPB[1].data[0])
674
+                if(h->DPB[1].f.data[0])
675 675
                     avctx->release_buffer(avctx, (AVFrame *)&h->DPB[1]);
676 676
                 h->got_keyframe = 1;
677 677
             }
... ...
@@ -685,7 +685,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
685 685
                 break;
686 686
             *data_size = sizeof(AVPicture);
687 687
             if(h->pic_type != AV_PICTURE_TYPE_B) {
688
-                if(h->DPB[1].data[0]) {
688
+                if(h->DPB[1].f.data[0]) {
689 689
                     *picture = *(AVFrame *) &h->DPB[1];
690 690
                 } else {
691 691
                     *data_size = 0;
... ...
@@ -24,7 +24,7 @@
24 24
 
25 25
 void *ff_dxva2_get_surface(const Picture *picture)
26 26
 {
27
-    return picture->data[3];
27
+    return picture->f.data[3];
28 28
 }
29 29
 
30 30
 unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx,
... ...
@@ -70,15 +70,15 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
70 70
                                ff_dxva2_get_surface_index(ctx, r),
71 71
                                r->long_ref != 0);
72 72
 
73
-            if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX)
73
+            if ((r->f.reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX)
74 74
                 pp->FieldOrderCntList[i][0] = r->field_poc[0];
75
-            if ((r->reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX)
75
+            if ((r->f.reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX)
76 76
                 pp->FieldOrderCntList[i][1] = r->field_poc[1];
77 77
 
78 78
             pp->FrameNumList[i] = r->long_ref ? r->pic_id : r->frame_num;
79
-            if (r->reference & PICT_TOP_FIELD)
79
+            if (r->f.reference & PICT_TOP_FIELD)
80 80
                 pp->UsedForReferenceFlags |= 1 << (2*i + 0);
81
-            if (r->reference & PICT_BOTTOM_FIELD)
81
+            if (r->f.reference & PICT_BOTTOM_FIELD)
82 82
                 pp->UsedForReferenceFlags |= 1 << (2*i + 1);
83 83
         } else {
84 84
             pp->RefFrameList[i].bPicEntry = 0xff;
... ...
@@ -229,7 +229,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
229 229
                 unsigned plane;
230 230
                 fill_picture_entry(&slice->RefPicList[list][i],
231 231
                                    ff_dxva2_get_surface_index(ctx, r),
232
-                                   r->reference == PICT_BOTTOM_FIELD);
232
+                                   r->f.reference == PICT_BOTTOM_FIELD);
233 233
                 for (plane = 0; plane < 3; plane++) {
234 234
                     int w, o;
235 235
                     if (plane == 0 && h->luma_weight_flag[list]) {
... ...
@@ -278,7 +278,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
278 278
     const unsigned mb_count = s->mb_width * s->mb_height;
279 279
     struct dxva_context *ctx = avctx->hwaccel_context;
280 280
     const Picture *current_picture = h->s.current_picture_ptr;
281
-    struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
281
+    struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private;
282 282
     DXVA_Slice_H264_Short *slice = NULL;
283 283
     uint8_t  *dxva_data, *current, *end;
284 284
     unsigned dxva_size;
... ...
@@ -373,7 +373,7 @@ static int start_frame(AVCodecContext *avctx,
373 373
 {
374 374
     const H264Context *h = avctx->priv_data;
375 375
     struct dxva_context *ctx = avctx->hwaccel_context;
376
-    struct dxva2_picture_context *ctx_pic = h->s.current_picture_ptr->hwaccel_picture_private;
376
+    struct dxva2_picture_context *ctx_pic = h->s.current_picture_ptr->f.hwaccel_picture_private;
377 377
 
378 378
     if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
379 379
         return -1;
... ...
@@ -397,7 +397,7 @@ static int decode_slice(AVCodecContext *avctx,
397 397
     const H264Context *h = avctx->priv_data;
398 398
     struct dxva_context *ctx = avctx->hwaccel_context;
399 399
     const Picture *current_picture = h->s.current_picture_ptr;
400
-    struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
400
+    struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private;
401 401
     unsigned position;
402 402
 
403 403
     if (ctx_pic->slice_count >= MAX_SLICES)
... ...
@@ -426,7 +426,7 @@ static int end_frame(AVCodecContext *avctx)
426 426
     H264Context *h = avctx->priv_data;
427 427
     MpegEncContext *s = &h->s;
428 428
     struct dxva2_picture_context *ctx_pic =
429
-        h->s.current_picture_ptr->hwaccel_picture_private;
429
+        h->s.current_picture_ptr->f.hwaccel_picture_private;
430 430
 
431 431
     if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
432 432
         return -1;
... ...
@@ -151,7 +151,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
151 151
     const struct MpegEncContext *s = avctx->priv_data;
152 152
     struct dxva_context *ctx = avctx->hwaccel_context;
153 153
     struct dxva2_picture_context *ctx_pic =
154
-        s->current_picture_ptr->hwaccel_picture_private;
154
+        s->current_picture_ptr->f.hwaccel_picture_private;
155 155
     const int is_field = s->picture_structure != PICT_FRAME;
156 156
     const unsigned mb_count = s->mb_width * (s->mb_height >> is_field);
157 157
     uint8_t  *dxva_data, *current, *end;
... ...
@@ -210,7 +210,7 @@ static int start_frame(AVCodecContext *avctx,
210 210
     const struct MpegEncContext *s = avctx->priv_data;
211 211
     struct dxva_context *ctx = avctx->hwaccel_context;
212 212
     struct dxva2_picture_context *ctx_pic =
213
-        s->current_picture_ptr->hwaccel_picture_private;
213
+        s->current_picture_ptr->f.hwaccel_picture_private;
214 214
 
215 215
     if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
216 216
         return -1;
... ...
@@ -230,7 +230,7 @@ static int decode_slice(AVCodecContext *avctx,
230 230
 {
231 231
     const struct MpegEncContext *s = avctx->priv_data;
232 232
     struct dxva2_picture_context *ctx_pic =
233
-        s->current_picture_ptr->hwaccel_picture_private;
233
+        s->current_picture_ptr->f.hwaccel_picture_private;
234 234
     unsigned position;
235 235
 
236 236
     if (ctx_pic->slice_count >= MAX_SLICES)
... ...
@@ -250,7 +250,7 @@ static int end_frame(AVCodecContext *avctx)
250 250
 {
251 251
     struct MpegEncContext *s = avctx->priv_data;
252 252
     struct dxva2_picture_context *ctx_pic =
253
-        s->current_picture_ptr->hwaccel_picture_private;
253
+        s->current_picture_ptr->f.hwaccel_picture_private;
254 254
 
255 255
     if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
256 256
         return -1;
... ...
@@ -161,7 +161,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
161 161
     const VC1Context *v = avctx->priv_data;
162 162
     struct dxva_context *ctx = avctx->hwaccel_context;
163 163
     const MpegEncContext *s = &v->s;
164
-    struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private;
164
+    struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->f.hwaccel_picture_private;
165 165
 
166 166
     DXVA_SliceInfo *slice = &ctx_pic->si;
167 167
 
... ...
@@ -213,7 +213,7 @@ static int start_frame(AVCodecContext *avctx,
213 213
 {
214 214
     const VC1Context *v = avctx->priv_data;
215 215
     struct dxva_context *ctx = avctx->hwaccel_context;
216
-    struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
216
+    struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->f.hwaccel_picture_private;
217 217
 
218 218
     if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
219 219
         return -1;
... ...
@@ -231,7 +231,7 @@ static int decode_slice(AVCodecContext *avctx,
231 231
 {
232 232
     const VC1Context *v = avctx->priv_data;
233 233
     const Picture *current_picture = v->s.current_picture_ptr;
234
-    struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
234
+    struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private;
235 235
 
236 236
     if (ctx_pic->bitstream_size > 0)
237 237
         return -1;
... ...
@@ -252,7 +252,7 @@ static int decode_slice(AVCodecContext *avctx,
252 252
 static int end_frame(AVCodecContext *avctx)
253 253
 {
254 254
     VC1Context *v = avctx->priv_data;
255
-    struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
255
+    struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->f.hwaccel_picture_private;
256 256
 
257 257
     if (ctx_pic->bitstream_size <= 0)
258 258
         return -1;
... ...
@@ -41,9 +41,9 @@
41 41
 #undef mb_intra
42 42
 
43 43
 static void decode_mb(MpegEncContext *s, int ref){
44
-    s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize  ) + s->mb_x * 16;
45
-    s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
46
-    s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
44
+    s->dest[0] = s->current_picture.f.data[0] + (s->mb_y *  16 * s->linesize)                         + s->mb_x *  16;
45
+    s->dest[1] = s->current_picture.f.data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
46
+    s->dest[2] = s->current_picture.f.data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
47 47
 
48 48
     if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
49 49
         H264Context *h= (void*)s;
... ...
@@ -52,7 +52,7 @@ static void decode_mb(MpegEncContext *s, int ref){
52 52
         assert(ref>=0);
53 53
         if(ref >= h->ref_count[0]) //FIXME it is posible albeit uncommon that slice references differ between slices, we take the easy approuch and ignore it for now. If this turns out to have any relevance in practice then correct remapping should be added
54 54
             ref=0;
55
-        fill_rectangle(&s->current_picture.ref_index[0][4*h->mb_xy], 2, 2, 2, ref, 1);
55
+        fill_rectangle(&s->current_picture.f.ref_index[0][4*h->mb_xy], 2, 2, 2, ref, 1);
56 56
         fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
57 57
         fill_rectangle(h->mv_cache[0][ scan8[0] ], 4, 4, 8, pack16to32(s->mv[0][0][0],s->mv[0][0][1]), 4);
58 58
         assert(!FRAME_MBAFF);
... ...
@@ -166,14 +166,14 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
166 166
 
167 167
             error= s->error_status_table[mb_index];
168 168
 
169
-            if(IS_INTER(s->current_picture.mb_type[mb_index])) continue; //inter
169
+            if(IS_INTER(s->current_picture.f.mb_type[mb_index])) continue; //inter
170 170
             if(!(error&DC_ERROR)) continue;           //dc-ok
171 171
 
172 172
             /* right block */
173 173
             for(j=b_x+1; j<w; j++){
174 174
                 int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride;
175 175
                 int error_j= s->error_status_table[mb_index_j];
176
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
176
+                int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
177 177
                 if(intra_j==0 || !(error_j&DC_ERROR)){
178 178
                     color[0]= dc[j + b_y*stride];
179 179
                     distance[0]= j-b_x;
... ...
@@ -185,7 +185,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
185 185
             for(j=b_x-1; j>=0; j--){
186 186
                 int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride;
187 187
                 int error_j= s->error_status_table[mb_index_j];
188
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
188
+                int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
189 189
                 if(intra_j==0 || !(error_j&DC_ERROR)){
190 190
                     color[1]= dc[j + b_y*stride];
191 191
                     distance[1]= b_x-j;
... ...
@@ -197,7 +197,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
197 197
             for(j=b_y+1; j<h; j++){
198 198
                 int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride;
199 199
                 int error_j= s->error_status_table[mb_index_j];
200
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
200
+                int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
201 201
                 if(intra_j==0 || !(error_j&DC_ERROR)){
202 202
                     color[2]= dc[b_x + j*stride];
203 203
                     distance[2]= j-b_y;
... ...
@@ -209,7 +209,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
209 209
             for(j=b_y-1; j>=0; j--){
210 210
                 int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride;
211 211
                 int error_j= s->error_status_table[mb_index_j];
212
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
212
+                int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
213 213
                 if(intra_j==0 || !(error_j&DC_ERROR)){
214 214
                     color[3]= dc[b_x + j*stride];
215 215
                     distance[3]= b_y-j;
... ...
@@ -248,13 +248,13 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
248 248
             int y;
249 249
             int left_status = s->error_status_table[( b_x   >>is_luma) + (b_y>>is_luma)*s->mb_stride];
250 250
             int right_status= s->error_status_table[((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride];
251
-            int left_intra=   IS_INTRA(s->current_picture.mb_type      [( b_x   >>is_luma) + (b_y>>is_luma)*s->mb_stride]);
252
-            int right_intra=  IS_INTRA(s->current_picture.mb_type      [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]);
251
+            int left_intra  = IS_INTRA(s->current_picture.f.mb_type[( b_x      >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
252
+            int right_intra = IS_INTRA(s->current_picture.f.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
253 253
             int left_damage =  left_status&(DC_ERROR|AC_ERROR|MV_ERROR);
254 254
             int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR);
255 255
             int offset= b_x*8 + b_y*stride*8;
256
-            int16_t *left_mv=  s->current_picture.motion_val[0][mvy_stride*b_y + mvx_stride* b_x   ];
257
-            int16_t *right_mv= s->current_picture.motion_val[0][mvy_stride*b_y + mvx_stride*(b_x+1)];
256
+            int16_t *left_mv=  s->current_picture.f.motion_val[0][mvy_stride*b_y + mvx_stride* b_x   ];
257
+            int16_t *right_mv= s->current_picture.f.motion_val[0][mvy_stride*b_y + mvx_stride*(b_x+1)];
258 258
 
259 259
             if(!(left_damage||right_damage)) continue; // both undamaged
260 260
 
... ...
@@ -311,13 +311,13 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
311 311
             int x;
312 312
             int top_status   = s->error_status_table[(b_x>>is_luma) + ( b_y   >>is_luma)*s->mb_stride];
313 313
             int bottom_status= s->error_status_table[(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride];
314
-            int top_intra=     IS_INTRA(s->current_picture.mb_type      [(b_x>>is_luma) + ( b_y   >>is_luma)*s->mb_stride]);
315
-            int bottom_intra=  IS_INTRA(s->current_picture.mb_type      [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]);
314
+            int top_intra    = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ( b_y      >> is_luma) * s->mb_stride]);
315
+            int bottom_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);
316 316
             int top_damage =      top_status&(DC_ERROR|AC_ERROR|MV_ERROR);
317 317
             int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR);
318 318
             int offset= b_x*8 + b_y*stride*8;
319
-            int16_t *top_mv=    s->current_picture.motion_val[0][mvy_stride* b_y    + mvx_stride*b_x];
320
-            int16_t *bottom_mv= s->current_picture.motion_val[0][mvy_stride*(b_y+1) + mvx_stride*b_x];
319
+            int16_t *top_mv    = s->current_picture.f.motion_val[0][mvy_stride *  b_y      + mvx_stride * b_x];
320
+            int16_t *bottom_mv = s->current_picture.f.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
321 321
 
322 322
             if(!(top_damage||bottom_damage)) continue; // both undamaged
323 323
 
... ...
@@ -376,19 +376,19 @@ static void guess_mv(MpegEncContext *s){
376 376
         int f=0;
377 377
         int error= s->error_status_table[mb_xy];
378 378
 
379
-        if(IS_INTRA(s->current_picture.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check
379
+        if(IS_INTRA(s->current_picture.f.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check
380 380
         if(!(error&MV_ERROR)) f=MV_FROZEN;           //inter with undamaged MV
381 381
 
382 382
         fixed[mb_xy]= f;
383 383
         if(f==MV_FROZEN)
384 384
             num_avail++;
385
-        else if(s->last_picture.data[0] && s->last_picture.motion_val[0]){
385
+        else if(s->last_picture.f.data[0] && s->last_picture.f.motion_val[0]){
386 386
             const int mb_y= mb_xy / s->mb_stride;
387 387
             const int mb_x= mb_xy % s->mb_stride;
388 388
             const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
389
-            s->current_picture.motion_val[0][mot_index][0]= s->last_picture.motion_val[0][mot_index][0];
390
-            s->current_picture.motion_val[0][mot_index][1]= s->last_picture.motion_val[0][mot_index][1];
391
-            s->current_picture.ref_index[0][4*mb_xy]      = s->last_picture.ref_index[0][4*mb_xy];
389
+            s->current_picture.f.motion_val[0][mot_index][0]= s->last_picture.f.motion_val[0][mot_index][0];
390
+            s->current_picture.f.motion_val[0][mot_index][1]= s->last_picture.f.motion_val[0][mot_index][1];
391
+            s->current_picture.f.ref_index[0][4*mb_xy]      = s->last_picture.f.ref_index[0][4*mb_xy];
392 392
         }
393 393
     }
394 394
 
... ...
@@ -397,10 +397,10 @@ static void guess_mv(MpegEncContext *s){
397 397
             for(mb_x=0; mb_x<s->mb_width; mb_x++){
398 398
                 const int mb_xy= mb_x + mb_y*s->mb_stride;
399 399
 
400
-                if(IS_INTRA(s->current_picture.mb_type[mb_xy]))  continue;
400
+                if(IS_INTRA(s->current_picture.f.mb_type[mb_xy]))  continue;
401 401
                 if(!(s->error_status_table[mb_xy]&MV_ERROR)) continue;
402 402
 
403
-                s->mv_dir = s->last_picture.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
403
+                s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
404 404
                 s->mb_intra=0;
405 405
                 s->mv_type = MV_TYPE_16X16;
406 406
                 s->mb_skipped=0;
... ...
@@ -442,8 +442,8 @@ int score_sum=0;
442 442
                     if((mb_x^mb_y^pass)&1) continue;
443 443
 
444 444
                     if(fixed[mb_xy]==MV_FROZEN) continue;
445
-                    assert(!IS_INTRA(s->current_picture.mb_type[mb_xy]));
446
-                    assert(s->last_picture_ptr && s->last_picture_ptr->data[0]);
445
+                    assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy]));
446
+                    assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]);
447 447
 
448 448
                     j=0;
449 449
                     if(mb_x>0           && fixed[mb_xy-1        ]==MV_FROZEN) j=1;
... ...
@@ -462,27 +462,27 @@ int score_sum=0;
462 462
                     none_left=0;
463 463
 
464 464
                     if(mb_x>0 && fixed[mb_xy-1]){
465
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_step][0];
466
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_step][1];
467
-                        ref         [pred_count]   = s->current_picture.ref_index[0][4*(mb_xy-1)];
465
+                        mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index - mot_step][0];
466
+                        mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index - mot_step][1];
467
+                        ref         [pred_count]   = s->current_picture.f.ref_index[0][4*(mb_xy-1)];
468 468
                         pred_count++;
469 469
                     }
470 470
                     if(mb_x+1<mb_width && fixed[mb_xy+1]){
471
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_step][0];
472
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_step][1];
473
-                        ref         [pred_count]   = s->current_picture.ref_index[0][4*(mb_xy+1)];
471
+                        mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index + mot_step][0];
472
+                        mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index + mot_step][1];
473
+                        ref         [pred_count]   = s->current_picture.f.ref_index[0][4*(mb_xy+1)];
474 474
                         pred_count++;
475 475
                     }
476 476
                     if(mb_y>0 && fixed[mb_xy-mb_stride]){
477
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][0];
478
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][1];
479
-                        ref         [pred_count]   = s->current_picture.ref_index[0][4*(mb_xy-s->mb_stride)];
477
+                        mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index - mot_stride*mot_step][0];
478
+                        mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index - mot_stride*mot_step][1];
479
+                        ref         [pred_count]   = s->current_picture.f.ref_index[0][4*(mb_xy-s->mb_stride)];
480 480
                         pred_count++;
481 481
                     }
482 482
                     if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){
483
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][0];
484
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][1];
485
-                        ref         [pred_count]   = s->current_picture.ref_index[0][4*(mb_xy+s->mb_stride)];
483
+                        mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index + mot_stride*mot_step][0];
484
+                        mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index + mot_stride*mot_step][1];
485
+                        ref         [pred_count]   = s->current_picture.f.ref_index[0][4*(mb_xy+s->mb_stride)];
486 486
                         pred_count++;
487 487
                     }
488 488
                     if(pred_count==0) continue;
... ...
@@ -542,16 +542,16 @@ skip_mean_and_median:
542 542
                             ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
543 543
                                                      mb_y, 0);
544 544
                         }
545
-                        if (!s->last_picture.motion_val[0] ||
546
-                            !s->last_picture.ref_index[0])
545
+                        if (!s->last_picture.f.motion_val[0] ||
546
+                            !s->last_picture.f.ref_index[0])
547 547
                             goto skip_last_mv;
548
-                        prev_x = s->last_picture.motion_val[0][mot_index][0];
549
-                        prev_y = s->last_picture.motion_val[0][mot_index][1];
550
-                        prev_ref = s->last_picture.ref_index[0][4*mb_xy];
548
+                        prev_x = s->last_picture.f.motion_val[0][mot_index][0];
549
+                        prev_y = s->last_picture.f.motion_val[0][mot_index][1];
550
+                        prev_ref = s->last_picture.f.ref_index[0][4*mb_xy];
551 551
                     } else {
552
-                        prev_x = s->current_picture.motion_val[0][mot_index][0];
553
-                        prev_y = s->current_picture.motion_val[0][mot_index][1];
554
-                        prev_ref = s->current_picture.ref_index[0][4*mb_xy];
552
+                        prev_x = s->current_picture.f.motion_val[0][mot_index][0];
553
+                        prev_y = s->current_picture.f.motion_val[0][mot_index][1];
554
+                        prev_ref = s->current_picture.f.ref_index[0][4*mb_xy];
555 555
                     }
556 556
 
557 557
                     /* last MV */
... ...
@@ -573,10 +573,10 @@ skip_mean_and_median:
573 573
 
574 574
                     for(j=0; j<pred_count; j++){
575 575
                         int score=0;
576
-                        uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
576
+                        uint8_t *src = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize;
577 577
 
578
-                        s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
579
-                        s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
578
+                        s->current_picture.f.motion_val[0][mot_index][0] = s->mv[0][0][0] = mv_predictor[j][0];
579
+                        s->current_picture.f.motion_val[0][mot_index][1] = s->mv[0][0][1] = mv_predictor[j][1];
580 580
 
581 581
                         if(ref[j]<0) //predictor intra or otherwise not available
582 582
                             continue;
... ...
@@ -615,8 +615,8 @@ score_sum+= best_score;
615 615
 
616 616
                     for(i=0; i<mot_step; i++)
617 617
                         for(j=0; j<mot_step; j++){
618
-                            s->current_picture.motion_val[0][mot_index+i+j*mot_stride][0]= s->mv[0][0][0];
619
-                            s->current_picture.motion_val[0][mot_index+i+j*mot_stride][1]= s->mv[0][0][1];
618
+                            s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
619
+                            s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
620 620
                         }
621 621
 
622 622
                     decode_mb(s, ref[best_pred]);
... ...
@@ -648,7 +648,7 @@ score_sum+= best_score;
648 648
 static int is_intra_more_likely(MpegEncContext *s){
649 649
     int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
650 650
 
651
-    if(!s->last_picture_ptr || !s->last_picture_ptr->data[0]) return 1; //no previous frame available -> use spatial prediction
651
+    if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1; //no previous frame available -> use spatial prediction
652 652
 
653 653
     undamaged_count=0;
654 654
     for(i=0; i<s->mb_num; i++){
... ...
@@ -660,7 +660,7 @@ static int is_intra_more_likely(MpegEncContext *s){
660 660
 
661 661
     if(s->codec_id == CODEC_ID_H264){
662 662
         H264Context *h= (void*)s;
663
-        if(h->ref_count[0] <= 0 || !h->ref_list[0][0].data[0])
663
+        if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0])
664 664
             return 1;
665 665
     }
666 666
 
... ...
@@ -687,8 +687,8 @@ static int is_intra_more_likely(MpegEncContext *s){
687 687
             if((j%skip_amount) != 0) continue; //skip a few to speed things up
688 688
 
689 689
             if(s->pict_type==AV_PICTURE_TYPE_I){
690
-                uint8_t *mb_ptr     = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
691
-                uint8_t *last_mb_ptr= s->last_picture.data   [0] + mb_x*16 + mb_y*16*s->linesize;
690
+                uint8_t *mb_ptr     = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize;
691
+                uint8_t *last_mb_ptr= s->last_picture.f.data   [0] + mb_x*16 + mb_y*16*s->linesize;
692 692
 
693 693
                 if (s->avctx->codec_id == CODEC_ID_H264) {
694 694
                     // FIXME
... ...
@@ -700,7 +700,7 @@ static int is_intra_more_likely(MpegEncContext *s){
700 700
                 // FIXME need await_progress() here
701 701
                 is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
702 702
             }else{
703
-                if(IS_INTRA(s->current_picture.mb_type[mb_xy]))
703
+                if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
704 704
                    is_intra_likely++;
705 705
                 else
706 706
                    is_intra_likely--;
... ...
@@ -802,15 +802,15 @@ void ff_er_frame_end(MpegEncContext *s){
802 802
        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
803 803
        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
804 804
 
805
-    if(s->current_picture.motion_val[0] == NULL){
805
+    if (s->current_picture.f.motion_val[0] == NULL) {
806 806
         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
807 807
 
808 808
         for(i=0; i<2; i++){
809
-            pic->ref_index[i]= av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
809
+            pic->f.ref_index[i] = av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
810 810
             pic->motion_val_base[i]= av_mallocz((size+4) * 2 * sizeof(uint16_t));
811
-            pic->motion_val[i]= pic->motion_val_base[i]+4;
811
+            pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
812 812
         }
813
-        pic->motion_subsample_log2= 3;
813
+        pic->f.motion_subsample_log2 = 3;
814 814
         s->current_picture= *s->current_picture_ptr;
815 815
     }
816 816
 
... ...
@@ -965,25 +965,25 @@ void ff_er_frame_end(MpegEncContext *s){
965 965
             continue;
966 966
 
967 967
         if(is_intra_likely)
968
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA4x4;
968
+            s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
969 969
         else
970
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_16x16 | MB_TYPE_L0;
970
+            s->current_picture.f.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
971 971
     }
972 972
 
973 973
     // change inter to intra blocks if no reference frames are available
974
-    if (!s->last_picture.data[0] && !s->next_picture.data[0])
974
+    if (!s->last_picture.f.data[0] && !s->next_picture.f.data[0])
975 975
         for(i=0; i<s->mb_num; i++){
976 976
             const int mb_xy= s->mb_index2xy[i];
977
-            if(!IS_INTRA(s->current_picture.mb_type[mb_xy]))
978
-                s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA4x4;
977
+            if (!IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
978
+                s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
979 979
         }
980 980
 
981 981
     /* handle inter blocks with damaged AC */
982 982
     for(mb_y=0; mb_y<s->mb_height; mb_y++){
983 983
         for(mb_x=0; mb_x<s->mb_width; mb_x++){
984 984
             const int mb_xy= mb_x + mb_y * s->mb_stride;
985
-            const int mb_type= s->current_picture.mb_type[mb_xy];
986
-            int dir = !s->last_picture.data[0];
985
+            const int mb_type= s->current_picture.f.mb_type[mb_xy];
986
+            int dir = !s->last_picture.f.data[0];
987 987
             error= s->error_status_table[mb_xy];
988 988
 
989 989
             if(IS_INTRA(mb_type)) continue; //intra
... ...
@@ -998,13 +998,13 @@ void ff_er_frame_end(MpegEncContext *s){
998 998
                 int j;
999 999
                 s->mv_type = MV_TYPE_8X8;
1000 1000
                 for(j=0; j<4; j++){
1001
-                    s->mv[0][j][0] = s->current_picture.motion_val[dir][ mb_index + (j&1) + (j>>1)*s->b8_stride ][0];
1002
-                    s->mv[0][j][1] = s->current_picture.motion_val[dir][ mb_index + (j&1) + (j>>1)*s->b8_stride ][1];
1001
+                    s->mv[0][j][0] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
1002
+                    s->mv[0][j][1] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
1003 1003
                 }
1004 1004
             }else{
1005 1005
                 s->mv_type = MV_TYPE_16X16;
1006
-                s->mv[0][0][0] = s->current_picture.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][0];
1007
-                s->mv[0][0][1] = s->current_picture.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][1];
1006
+                s->mv[0][0][0] = s->current_picture.f.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][0];
1007
+                s->mv[0][0][1] = s->current_picture.f.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][1];
1008 1008
             }
1009 1009
 
1010 1010
             s->dsp.clear_blocks(s->block[0]);
... ...
@@ -1021,7 +1021,7 @@ void ff_er_frame_end(MpegEncContext *s){
1021 1021
             for(mb_x=0; mb_x<s->mb_width; mb_x++){
1022 1022
                 int xy= mb_x*2 + mb_y*2*s->b8_stride;
1023 1023
                 const int mb_xy= mb_x + mb_y * s->mb_stride;
1024
-                const int mb_type= s->current_picture.mb_type[mb_xy];
1024
+                const int mb_type= s->current_picture.f.mb_type[mb_xy];
1025 1025
                 error= s->error_status_table[mb_xy];
1026 1026
 
1027 1027
                 if(IS_INTRA(mb_type)) continue;
... ...
@@ -1029,8 +1029,8 @@ void ff_er_frame_end(MpegEncContext *s){
1029 1029
                 if(!(error&AC_ERROR)) continue;           //undamaged inter
1030 1030
 
1031 1031
                 s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD;
1032
-                if(!s->last_picture.data[0]) s->mv_dir &= ~MV_DIR_FORWARD;
1033
-                if(!s->next_picture.data[0]) s->mv_dir &= ~MV_DIR_BACKWARD;
1032
+                if(!s->last_picture.f.data[0]) s->mv_dir &= ~MV_DIR_FORWARD;
1033
+                if(!s->next_picture.f.data[0]) s->mv_dir &= ~MV_DIR_BACKWARD;
1034 1034
                 s->mb_intra=0;
1035 1035
                 s->mv_type = MV_TYPE_16X16;
1036 1036
                 s->mb_skipped=0;
... ...
@@ -1045,10 +1045,10 @@ void ff_er_frame_end(MpegEncContext *s){
1045 1045
                         ff_thread_await_progress((AVFrame *) s->next_picture_ptr,
1046 1046
                                                  mb_y, 0);
1047 1047
                     }
1048
-                    s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp;
1049
-                    s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp;
1050
-                    s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;
1051
-                    s->mv[1][0][1] = s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;
1048
+                    s->mv[0][0][0] = s->next_picture.f.motion_val[0][xy][0] *            time_pb  / time_pp;
1049
+                    s->mv[0][0][1] = s->next_picture.f.motion_val[0][xy][1] *            time_pb  / time_pp;
1050
+                    s->mv[1][0][0] = s->next_picture.f.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
1051
+                    s->mv[1][0][1] = s->next_picture.f.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
1052 1052
                 }else{
1053 1053
                     s->mv[0][0][0]= 0;
1054 1054
                     s->mv[0][0][1]= 0;
... ...
@@ -1075,16 +1075,16 @@ void ff_er_frame_end(MpegEncContext *s){
1075 1075
             int16_t *dc_ptr;
1076 1076
             uint8_t *dest_y, *dest_cb, *dest_cr;
1077 1077
             const int mb_xy= mb_x + mb_y * s->mb_stride;
1078
-            const int mb_type= s->current_picture.mb_type[mb_xy];
1078
+            const int mb_type = s->current_picture.f.mb_type[mb_xy];
1079 1079
 
1080 1080
             error= s->error_status_table[mb_xy];
1081 1081
 
1082 1082
             if(IS_INTRA(mb_type) && s->partitioned_frame) continue;
1083 1083
 //            if(error&MV_ERROR) continue; //inter data damaged FIXME is this good?
1084 1084
 
1085
-            dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
1086
-            dest_cb= s->current_picture.data[1] + mb_x*8  + mb_y*8 *s->uvlinesize;
1087
-            dest_cr= s->current_picture.data[2] + mb_x*8  + mb_y*8 *s->uvlinesize;
1085
+            dest_y  = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize;
1086
+            dest_cb = s->current_picture.f.data[1] + mb_x *  8 + mb_y *  8 * s->uvlinesize;
1087
+            dest_cr = s->current_picture.f.data[2] + mb_x *  8 + mb_y *  8 * s->uvlinesize;
1088 1088
 
1089 1089
             dc_ptr= &s->dc_val[0][mb_x*2 + mb_y*2*s->b8_stride];
1090 1090
             for(n=0; n<4; n++){
... ...
@@ -1125,16 +1125,16 @@ void ff_er_frame_end(MpegEncContext *s){
1125 1125
         for(mb_x=0; mb_x<s->mb_width; mb_x++){
1126 1126
             uint8_t *dest_y, *dest_cb, *dest_cr;
1127 1127
             const int mb_xy= mb_x + mb_y * s->mb_stride;
1128
-            const int mb_type= s->current_picture.mb_type[mb_xy];
1128
+            const int mb_type = s->current_picture.f.mb_type[mb_xy];
1129 1129
 
1130 1130
             error= s->error_status_table[mb_xy];
1131 1131
 
1132 1132
             if(IS_INTER(mb_type)) continue;
1133 1133
             if(!(error&AC_ERROR)) continue;              //undamaged
1134 1134
 
1135
-            dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
1136
-            dest_cb= s->current_picture.data[1] + mb_x*8  + mb_y*8 *s->uvlinesize;
1137
-            dest_cr= s->current_picture.data[2] + mb_x*8  + mb_y*8 *s->uvlinesize;
1135
+            dest_y  = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize;
1136
+            dest_cb = s->current_picture.f.data[1] + mb_x *  8 + mb_y *  8 * s->uvlinesize;
1137
+            dest_cr = s->current_picture.f.data[2] + mb_x *  8 + mb_y *  8 * s->uvlinesize;
1138 1138
 
1139 1139
             put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1140 1140
         }
... ...
@@ -1143,14 +1143,14 @@ void ff_er_frame_end(MpegEncContext *s){
1143 1143
 
1144 1144
     if(s->avctx->error_concealment&FF_EC_DEBLOCK){
1145 1145
         /* filter horizontal block boundaries */
1146
-        h_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize  , 1);
1147
-        h_block_filter(s, s->current_picture.data[1], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1148
-        h_block_filter(s, s->current_picture.data[2], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1146
+        h_block_filter(s, s->current_picture.f.data[0], s->mb_width*2, s->mb_height*2, s->linesize  , 1);
1147
+        h_block_filter(s, s->current_picture.f.data[1], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1148
+        h_block_filter(s, s->current_picture.f.data[2], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1149 1149
 
1150 1150
         /* filter vertical block boundaries */
1151
-        v_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize  , 1);
1152
-        v_block_filter(s, s->current_picture.data[1], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1153
-        v_block_filter(s, s->current_picture.data[2], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1151
+        v_block_filter(s, s->current_picture.f.data[0], s->mb_width*2, s->mb_height*2, s->linesize  , 1);
1152
+        v_block_filter(s, s->current_picture.f.data[1], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1153
+        v_block_filter(s, s->current_picture.f.data[2], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
1154 1154
     }
1155 1155
 
1156 1156
 ec_clean:
... ...
@@ -215,7 +215,7 @@ static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2 )
215 215
 
216 216
         s->mv_dir = MV_DIR_FORWARD;
217 217
         s->mv_type = MV_TYPE_16X16;
218
-        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
218
+        s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
219 219
         s->mv[0][0][0] = 0;
220 220
         s->mv[0][0][1] = 0;
221 221
         s->mb_skipped = 1;
... ...
@@ -323,14 +323,14 @@ static int h261_decode_mb(H261Context *h){
323 323
     }
324 324
 
325 325
     if(s->mb_intra){
326
-        s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
326
+        s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
327 327
         goto intra;
328 328
     }
329 329
 
330 330
     //set motion vectors
331 331
     s->mv_dir = MV_DIR_FORWARD;
332 332
     s->mv_type = MV_TYPE_16X16;
333
-    s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
333
+    s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
334 334
     s->mv[0][0][0] = h->current_mv_x * 2;//gets divided by 2 in motion compensation
335 335
     s->mv[0][0][1] = h->current_mv_y * 2;
336 336
 
... ...
@@ -464,7 +464,7 @@ static int h261_decode_picture_header(H261Context *h){
464 464
     s->picture_number = (s->picture_number&~31) + i;
465 465
 
466 466
     s->avctx->time_base= (AVRational){1001, 30000};
467
-    s->current_picture.pts= s->picture_number;
467
+    s->current_picture.f.pts = s->picture_number;
468 468
 
469 469
 
470 470
     /* PTYPE starts here */
... ...
@@ -570,7 +570,7 @@ retry:
570 570
     }
571 571
 
572 572
     //we need to set current_picture_ptr before reading the header, otherwise we cannot store anyting im there
573
-    if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
573
+    if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
574 574
         int i= ff_find_unused_picture(s, 0);
575 575
         s->current_picture_ptr= &s->picture[i];
576 576
     }
... ...
@@ -596,8 +596,8 @@ retry:
596 596
     }
597 597
 
598 598
     // for skipping the frame
599
-    s->current_picture.pict_type= s->pict_type;
600
-    s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I;
599
+    s->current_picture.f.pict_type = s->pict_type;
600
+    s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
601 601
 
602 602
     if(  (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
603 603
        ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
... ...
@@ -52,7 +52,7 @@ void ff_h263_update_motion_val(MpegEncContext * s){
52 52
     const int wrap = s->b8_stride;
53 53
     const int xy = s->block_index[0];
54 54
 
55
-    s->current_picture.mbskip_table[mb_xy]= s->mb_skipped;
55
+    s->current_picture.f.mbskip_table[mb_xy] = s->mb_skipped;
56 56
 
57 57
     if(s->mv_type != MV_TYPE_8X8){
58 58
         int motion_x, motion_y;
... ...
@@ -71,30 +71,30 @@ void ff_h263_update_motion_val(MpegEncContext * s){
71 71
                 s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0];
72 72
                 s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1];
73 73
             }
74
-            s->current_picture.ref_index[0][4*mb_xy    ]=
75
-            s->current_picture.ref_index[0][4*mb_xy + 1]= s->field_select[0][0];
76
-            s->current_picture.ref_index[0][4*mb_xy + 2]=
77
-            s->current_picture.ref_index[0][4*mb_xy + 3]= s->field_select[0][1];
74
+            s->current_picture.f.ref_index[0][4*mb_xy    ] =
75
+            s->current_picture.f.ref_index[0][4*mb_xy + 1] = s->field_select[0][0];
76
+            s->current_picture.f.ref_index[0][4*mb_xy + 2] =
77
+            s->current_picture.f.ref_index[0][4*mb_xy + 3] = s->field_select[0][1];
78 78
         }
79 79
 
80 80
         /* no update if 8X8 because it has been done during parsing */
81
-        s->current_picture.motion_val[0][xy][0] = motion_x;
82
-        s->current_picture.motion_val[0][xy][1] = motion_y;
83
-        s->current_picture.motion_val[0][xy + 1][0] = motion_x;
84
-        s->current_picture.motion_val[0][xy + 1][1] = motion_y;
85
-        s->current_picture.motion_val[0][xy + wrap][0] = motion_x;
86
-        s->current_picture.motion_val[0][xy + wrap][1] = motion_y;
87
-        s->current_picture.motion_val[0][xy + 1 + wrap][0] = motion_x;
88
-        s->current_picture.motion_val[0][xy + 1 + wrap][1] = motion_y;
81
+        s->current_picture.f.motion_val[0][xy][0]            = motion_x;
82
+        s->current_picture.f.motion_val[0][xy][1]            = motion_y;
83
+        s->current_picture.f.motion_val[0][xy + 1][0]        = motion_x;
84
+        s->current_picture.f.motion_val[0][xy + 1][1]        = motion_y;
85
+        s->current_picture.f.motion_val[0][xy + wrap][0]     = motion_x;
86
+        s->current_picture.f.motion_val[0][xy + wrap][1]     = motion_y;
87
+        s->current_picture.f.motion_val[0][xy + 1 + wrap][0] = motion_x;
88
+        s->current_picture.f.motion_val[0][xy + 1 + wrap][1] = motion_y;
89 89
     }
90 90
 
91 91
     if(s->encoding){ //FIXME encoding MUST be cleaned up
92 92
         if (s->mv_type == MV_TYPE_8X8)
93
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_8x8;
93
+            s->current_picture.f.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_8x8;
94 94
         else if(s->mb_intra)
95
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA;
95
+            s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA;
96 96
         else
97
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16;
97
+            s->current_picture.f.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_16x16;
98 98
     }
99 99
 }
100 100
 
... ...
@@ -154,7 +154,7 @@ void ff_h263_loop_filter(MpegEncContext * s){
154 154
        Diag Top
155 155
        Left Center
156 156
     */
157
-    if(!IS_SKIP(s->current_picture.mb_type[xy])){
157
+    if (!IS_SKIP(s->current_picture.f.mb_type[xy])) {
158 158
         qp_c= s->qscale;
159 159
         s->dsp.h263_v_loop_filter(dest_y+8*linesize  , linesize, qp_c);
160 160
         s->dsp.h263_v_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
... ...
@@ -164,10 +164,10 @@ void ff_h263_loop_filter(MpegEncContext * s){
164 164
     if(s->mb_y){
165 165
         int qp_dt, qp_tt, qp_tc;
166 166
 
167
-        if(IS_SKIP(s->current_picture.mb_type[xy-s->mb_stride]))
167
+        if (IS_SKIP(s->current_picture.f.mb_type[xy - s->mb_stride]))
168 168
             qp_tt=0;
169 169
         else
170
-            qp_tt= s->current_picture.qscale_table[xy-s->mb_stride];
170
+            qp_tt = s->current_picture.f.qscale_table[xy - s->mb_stride];
171 171
 
172 172
         if(qp_c)
173 173
             qp_tc= qp_c;
... ...
@@ -187,10 +187,10 @@ void ff_h263_loop_filter(MpegEncContext * s){
187 187
             s->dsp.h263_h_loop_filter(dest_y-8*linesize+8  ,   linesize, qp_tt);
188 188
 
189 189
         if(s->mb_x){
190
-            if(qp_tt || IS_SKIP(s->current_picture.mb_type[xy-1-s->mb_stride]))
190
+            if (qp_tt || IS_SKIP(s->current_picture.f.mb_type[xy - 1 - s->mb_stride]))
191 191
                 qp_dt= qp_tt;
192 192
             else
193
-                qp_dt= s->current_picture.qscale_table[xy-1-s->mb_stride];
193
+                qp_dt = s->current_picture.f.qscale_table[xy - 1 - s->mb_stride];
194 194
 
195 195
             if(qp_dt){
196 196
                 const int chroma_qp= s->chroma_qscale_table[qp_dt];
... ...
@@ -209,10 +209,10 @@ void ff_h263_loop_filter(MpegEncContext * s){
209 209
 
210 210
     if(s->mb_x){
211 211
         int qp_lc;
212
-        if(qp_c || IS_SKIP(s->current_picture.mb_type[xy-1]))
212
+        if (qp_c || IS_SKIP(s->current_picture.f.mb_type[xy - 1]))
213 213
             qp_lc= qp_c;
214 214
         else
215
-            qp_lc= s->current_picture.qscale_table[xy-1];
215
+            qp_lc = s->current_picture.f.qscale_table[xy - 1];
216 216
 
217 217
         if(qp_lc){
218 218
             s->dsp.h263_h_loop_filter(dest_y,   linesize, qp_lc);
... ...
@@ -321,7 +321,7 @@ int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
321 321
     static const int off[4]= {2, 1, 1, -1};
322 322
 
323 323
     wrap = s->b8_stride;
324
-    mot_val = s->current_picture.motion_val[dir] + s->block_index[block];
324
+    mot_val = s->current_picture.f.motion_val[dir] + s->block_index[block];
325 325
 
326 326
     A = mot_val[ - 1];
327 327
     /* special case for first (slice) line */
... ...
@@ -406,7 +406,7 @@ retry:
406 406
 
407 407
     /* We need to set current_picture_ptr before reading the header,
408 408
      * otherwise we cannot store anyting in there */
409
-    if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
409
+    if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
410 410
         int i= ff_find_unused_picture(s, 0);
411 411
         s->current_picture_ptr= &s->picture[i];
412 412
     }
... ...
@@ -593,8 +593,8 @@ retry:
593 593
         s->gob_index = ff_h263_get_gob_height(s);
594 594
 
595 595
     // for skipping the frame
596
-    s->current_picture.pict_type= s->pict_type;
597
-    s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I;
596
+    s->current_picture.f.pict_type = s->pict_type;
597
+    s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
598 598
 
599 599
     /* skip B-frames if we don't have reference frames */
600 600
     if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)) return get_consumed_bytes(s, buf_size);
... ...
@@ -261,8 +261,8 @@ static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int
261 261
         // Error resilience puts the current picture in the ref list.
262 262
         // Don't try to wait on these as it will cause a deadlock.
263 263
         // Fields can wait on each other, though.
264
-        if(ref->thread_opaque != s->current_picture.thread_opaque ||
265
-           (ref->reference&3) != s->picture_structure) {
264
+        if (ref->f.thread_opaque != s->current_picture.f.thread_opaque ||
265
+           (ref->f.reference & 3) != s->picture_structure) {
266 266
             my = get_lowest_part_list_y(h, ref, n, height, y_offset, 0);
267 267
             if (refs[0][ref_n] < 0) nrefs[0] += 1;
268 268
             refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
... ...
@@ -273,8 +273,8 @@ static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int
273 273
         int ref_n = h->ref_cache[1][ scan8[n] ];
274 274
         Picture *ref= &h->ref_list[1][ref_n];
275 275
 
276
-        if(ref->thread_opaque != s->current_picture.thread_opaque ||
277
-           (ref->reference&3) != s->picture_structure) {
276
+        if (ref->f.thread_opaque != s->current_picture.f.thread_opaque ||
277
+           (ref->f.reference & 3) != s->picture_structure) {
278 278
             my = get_lowest_part_list_y(h, ref, n, height, y_offset, 1);
279 279
             if (refs[1][ref_n] < 0) nrefs[1] += 1;
280 280
             refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
... ...
@@ -290,7 +290,7 @@ static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int
290 290
 static void await_references(H264Context *h){
291 291
     MpegEncContext * const s = &h->s;
292 292
     const int mb_xy= h->mb_xy;
293
-    const int mb_type= s->current_picture.mb_type[mb_xy];
293
+    const int mb_type = s->current_picture.f.mb_type[mb_xy];
294 294
     int refs[2][48];
295 295
     int nrefs[2] = {0};
296 296
     int ref, list;
... ...
@@ -350,7 +350,7 @@ static void await_references(H264Context *h){
350 350
             int row = refs[list][ref];
351 351
             if(row >= 0){
352 352
                 Picture *ref_pic = &h->ref_list[list][ref];
353
-                int ref_field = ref_pic->reference - 1;
353
+                int ref_field = ref_pic->f.reference - 1;
354 354
                 int ref_field_picture = ref_pic->field_picture;
355 355
                 int pic_height = 16*s->mb_height >> ref_field_picture;
356 356
 
... ...
@@ -448,7 +448,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
448 448
     int my=       h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8;
449 449
     const int luma_xy= (mx&3) + ((my&3)<<2);
450 450
     int offset = ((mx>>2) << pixel_shift) + (my>>2)*h->mb_linesize;
451
-    uint8_t * src_y = pic->data[0] + offset;
451
+    uint8_t * src_y = pic->f.data[0] + offset;
452 452
     uint8_t * src_cb, * src_cr;
453 453
     int extra_width= h->emu_edge_width;
454 454
     int extra_height= h->emu_edge_height;
... ...
@@ -478,7 +478,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
478 478
     if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return;
479 479
 
480 480
     if(chroma444){
481
-        src_cb = pic->data[1] + offset;
481
+        src_cb = pic->f.data[1] + offset;
482 482
         if(emu){
483 483
             s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize,
484 484
                                     16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
... ...
@@ -489,7 +489,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
489 489
             qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize);
490 490
         }
491 491
 
492
-        src_cr = pic->data[2] + offset;
492
+        src_cr = pic->f.data[2] + offset;
493 493
         if(emu){
494 494
             s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize,
495 495
                                     16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
... ...
@@ -504,11 +504,11 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
504 504
 
505 505
     if(MB_FIELD){
506 506
         // chroma offset when predicting from a field of opposite parity
507
-        my += 2 * ((s->mb_y & 1) - (pic->reference - 1));
507
+        my += 2 * ((s->mb_y & 1) - (pic->f.reference - 1));
508 508
         emu |= (my>>3) < 0 || (my>>3) + 8 >= (pic_height>>1);
509 509
     }
510
-    src_cb= pic->data[1] + ((mx>>3) << pixel_shift) + (my>>3)*h->mb_uvlinesize;
511
-    src_cr= pic->data[2] + ((mx>>3) << pixel_shift) + (my>>3)*h->mb_uvlinesize;
510
+    src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) + (my >> 3) * h->mb_uvlinesize;
511
+    src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) + (my >> 3) * h->mb_uvlinesize;
512 512
 
513 513
     if(emu){
514 514
         s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
... ...
@@ -664,8 +664,8 @@ static inline void prefetch_motion(H264Context *h, int list, int pixel_shift, in
664 664
     if(refn >= 0){
665 665
         const int mx= (h->mv_cache[list][scan8[0]][0]>>2) + 16*s->mb_x + 8;
666 666
         const int my= (h->mv_cache[list][scan8[0]][1]>>2) + 16*s->mb_y;
667
-        uint8_t **src= h->ref_list[list][refn].data;
668
-        int off= ((mx+64)<<h->pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize;
667
+        uint8_t **src = h->ref_list[list][refn].f.data;
668
+        int off= (mx << pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize + (64 << pixel_shift);
669 669
         s->dsp.prefetch(src[0]+off, s->linesize, 4);
670 670
         if(chroma444){
671 671
             s->dsp.prefetch(src[1]+off, s->linesize, 4);
... ...
@@ -684,7 +684,7 @@ static av_always_inline void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t
684 684
                       int pixel_shift, int chroma444){
685 685
     MpegEncContext * const s = &h->s;
686 686
     const int mb_xy= h->mb_xy;
687
-    const int mb_type= s->current_picture.mb_type[mb_xy];
687
+    const int mb_type = s->current_picture.f.mb_type[mb_xy];
688 688
 
689 689
     assert(IS_INTER(mb_type));
690 690
 
... ...
@@ -1220,7 +1220,7 @@ int ff_h264_frame_start(H264Context *h){
1220 1220
      * Zero here; IDR markings per slice in frame or fields are ORed in later.
1221 1221
      * See decode_nal_units().
1222 1222
      */
1223
-    s->current_picture_ptr->key_frame= 0;
1223
+    s->current_picture_ptr->f.key_frame = 0;
1224 1224
     s->current_picture_ptr->mmco_reset= 0;
1225 1225
 
1226 1226
     assert(s->linesize && s->uvlinesize);
... ...
@@ -1245,7 +1245,7 @@ int ff_h264_frame_start(H264Context *h){
1245 1245
     /* some macroblocks can be accessed before they're available in case of lost slices, mbaff or threading*/
1246 1246
     memset(h->slice_table, -1, (s->mb_height*s->mb_stride-1) * sizeof(*h->slice_table));
1247 1247
 
1248
-//    s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1;
1248
+//    s->decode = (s->flags & CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.f.reference /*|| h->contains_intra*/ || 1;
1249 1249
 
1250 1250
     // We mark the current picture as non-reference after allocating it, so
1251 1251
     // that if we break out due to an error it can be released automatically
... ...
@@ -1254,7 +1254,7 @@ int ff_h264_frame_start(H264Context *h){
1254 1254
     // get released even with set reference, besides SVQ3 and others do not
1255 1255
     // mark frames as reference later "naturally".
1256 1256
     if(s->codec_id != CODEC_ID_SVQ3)
1257
-        s->current_picture_ptr->reference= 0;
1257
+        s->current_picture_ptr->f.reference = 0;
1258 1258
 
1259 1259
     s->current_picture_ptr->field_poc[0]=
1260 1260
     s->current_picture_ptr->field_poc[1]= INT_MAX;
... ...
@@ -1280,8 +1280,8 @@ static void decode_postinit(H264Context *h, int setup_finished){
1280 1280
     Picture *cur = s->current_picture_ptr;
1281 1281
     int i, pics, out_of_order, out_idx;
1282 1282
 
1283
-    s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
1284
-    s->current_picture_ptr->pict_type= s->pict_type;
1283
+    s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_H264;
1284
+    s->current_picture_ptr->f.pict_type   = s->pict_type;
1285 1285
 
1286 1286
     if (h->next_output_pic) return;
1287 1287
 
... ...
@@ -1294,8 +1294,8 @@ static void decode_postinit(H264Context *h, int setup_finished){
1294 1294
         return;
1295 1295
     }
1296 1296
 
1297
-    cur->interlaced_frame = 0;
1298
-    cur->repeat_pict = 0;
1297
+    cur->f.interlaced_frame = 0;
1298
+    cur->f.repeat_pict      = 0;
1299 1299
 
1300 1300
     /* Signal interlacing information externally. */
1301 1301
     /* Prioritize picture timing SEI information over used decoding process if it exists. */
... ...
@@ -1307,53 +1307,53 @@ static void decode_postinit(H264Context *h, int setup_finished){
1307 1307
             break;
1308 1308
         case SEI_PIC_STRUCT_TOP_FIELD:
1309 1309
         case SEI_PIC_STRUCT_BOTTOM_FIELD:
1310
-            cur->interlaced_frame = 1;
1310
+            cur->f.interlaced_frame = 1;
1311 1311
             break;
1312 1312
         case SEI_PIC_STRUCT_TOP_BOTTOM:
1313 1313
         case SEI_PIC_STRUCT_BOTTOM_TOP:
1314 1314
             if (FIELD_OR_MBAFF_PICTURE)
1315
-                cur->interlaced_frame = 1;
1315
+                cur->f.interlaced_frame = 1;
1316 1316
             else
1317 1317
                 // try to flag soft telecine progressive
1318
-                cur->interlaced_frame = h->prev_interlaced_frame;
1318
+                cur->f.interlaced_frame = h->prev_interlaced_frame;
1319 1319
             break;
1320 1320
         case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
1321 1321
         case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
1322 1322
             // Signal the possibility of telecined film externally (pic_struct 5,6)
1323 1323
             // From these hints, let the applications decide if they apply deinterlacing.
1324
-            cur->repeat_pict = 1;
1324
+            cur->f.repeat_pict = 1;
1325 1325
             break;
1326 1326
         case SEI_PIC_STRUCT_FRAME_DOUBLING:
1327 1327
             // Force progressive here, as doubling interlaced frame is a bad idea.
1328
-            cur->repeat_pict = 2;
1328
+            cur->f.repeat_pict = 2;
1329 1329
             break;
1330 1330
         case SEI_PIC_STRUCT_FRAME_TRIPLING:
1331
-            cur->repeat_pict = 4;
1331
+            cur->f.repeat_pict = 4;
1332 1332
             break;
1333 1333
         }
1334 1334
 
1335 1335
         if ((h->sei_ct_type & 3) && h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
1336
-            cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0;
1336
+            cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
1337 1337
     }else{
1338 1338
         /* Derive interlacing flag from used decoding process. */
1339
-        cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
1339
+        cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE;
1340 1340
     }
1341
-    h->prev_interlaced_frame = cur->interlaced_frame;
1341
+    h->prev_interlaced_frame = cur->f.interlaced_frame;
1342 1342
 
1343 1343
     if (cur->field_poc[0] != cur->field_poc[1]){
1344 1344
         /* Derive top_field_first from field pocs. */
1345
-        cur->top_field_first = cur->field_poc[0] < cur->field_poc[1];
1345
+        cur->f.top_field_first = cur->field_poc[0] < cur->field_poc[1];
1346 1346
     }else{
1347
-        if(cur->interlaced_frame || h->sps.pic_struct_present_flag){
1347
+        if (cur->f.interlaced_frame || h->sps.pic_struct_present_flag) {
1348 1348
             /* Use picture timing SEI information. Even if it is a information of a past frame, better than nothing. */
1349 1349
             if(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM
1350 1350
               || h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
1351
-                cur->top_field_first = 1;
1351
+                cur->f.top_field_first = 1;
1352 1352
             else
1353
-                cur->top_field_first = 0;
1353
+                cur->f.top_field_first = 0;
1354 1354
         }else{
1355 1355
             /* Most likely progressive */
1356
-            cur->top_field_first = 0;
1356
+            cur->f.top_field_first = 0;
1357 1357
         }
1358 1358
     }
1359 1359
 
... ...
@@ -1379,17 +1379,17 @@ static void decode_postinit(H264Context *h, int setup_finished){
1379 1379
     assert(pics <= MAX_DELAYED_PIC_COUNT);
1380 1380
 
1381 1381
     h->delayed_pic[pics++] = cur;
1382
-    if(cur->reference == 0)
1383
-        cur->reference = DELAYED_PIC_REF;
1382
+    if (cur->f.reference == 0)
1383
+        cur->f.reference = DELAYED_PIC_REF;
1384 1384
 
1385 1385
     out = h->delayed_pic[0];
1386 1386
     out_idx = 0;
1387
-    for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++)
1387
+    for (i = 1; h->delayed_pic[i] && !h->delayed_pic[i]->f.key_frame && !h->delayed_pic[i]->mmco_reset; i++)
1388 1388
         if(h->delayed_pic[i]->poc < out->poc){
1389 1389
             out = h->delayed_pic[i];
1390 1390
             out_idx = i;
1391 1391
         }
1392
-    if(s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset))
1392
+    if (s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset))
1393 1393
         h->next_outputed_poc= INT_MIN;
1394 1394
     out_of_order = out->poc < h->next_outputed_poc;
1395 1395
 
... ...
@@ -1398,14 +1398,14 @@ static void decode_postinit(H264Context *h, int setup_finished){
1398 1398
     else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT)
1399 1399
        || (s->low_delay &&
1400 1400
         ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2)
1401
-         || cur->pict_type == AV_PICTURE_TYPE_B)))
1401
+         || cur->f.pict_type == AV_PICTURE_TYPE_B)))
1402 1402
     {
1403 1403
         s->low_delay = 0;
1404 1404
         s->avctx->has_b_frames++;
1405 1405
     }
1406 1406
 
1407 1407
     if(out_of_order || pics > s->avctx->has_b_frames){
1408
-        out->reference &= ~DELAYED_PIC_REF;
1408
+        out->f.reference &= ~DELAYED_PIC_REF;
1409 1409
         out->owner2 = s; // for frame threading, the owner must be the second field's thread
1410 1410
                          // or else the first thread can release the picture and reuse it unsafely
1411 1411
         for(i=out_idx; h->delayed_pic[i]; i++)
... ...
@@ -1413,7 +1413,7 @@ static void decode_postinit(H264Context *h, int setup_finished){
1413 1413
     }
1414 1414
     if(!out_of_order && pics > s->avctx->has_b_frames){
1415 1415
         h->next_output_pic = out;
1416
-        if(out_idx==0 && h->delayed_pic[0] && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) {
1416
+        if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
1417 1417
             h->next_outputed_poc = INT_MIN;
1418 1418
         } else
1419 1419
             h->next_outputed_poc = out->poc;
... ...
@@ -1757,7 +1757,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i
1757 1757
     const int mb_x= s->mb_x;
1758 1758
     const int mb_y= s->mb_y;
1759 1759
     const int mb_xy= h->mb_xy;
1760
-    const int mb_type= s->current_picture.mb_type[mb_xy];
1760
+    const int mb_type = s->current_picture.f.mb_type[mb_xy];
1761 1761
     uint8_t  *dest_y, *dest_cb, *dest_cr;
1762 1762
     int linesize, uvlinesize /*dct_offset*/;
1763 1763
     int i, j;
... ...
@@ -1767,9 +1767,9 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i
1767 1767
     const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264;
1768 1768
     void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
1769 1769
 
1770
-    dest_y  = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize  ) * 16;
1771
-    dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
1772
-    dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
1770
+    dest_y  = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize  ) * 16;
1771
+    dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) *  8;
1772
+    dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) *  8;
1773 1773
 
1774 1774
     s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4);
1775 1775
     s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64 << pixel_shift), dest_cr - dest_cb, 2);
... ...
@@ -1921,7 +1921,7 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl
1921 1921
     const int mb_x= s->mb_x;
1922 1922
     const int mb_y= s->mb_y;
1923 1923
     const int mb_xy= h->mb_xy;
1924
-    const int mb_type= s->current_picture.mb_type[mb_xy];
1924
+    const int mb_type = s->current_picture.f.mb_type[mb_xy];
1925 1925
     uint8_t  *dest[3];
1926 1926
     int linesize;
1927 1927
     int i, j, p;
... ...
@@ -1931,7 +1931,7 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl
1931 1931
 
1932 1932
     for (p = 0; p < plane_count; p++)
1933 1933
     {
1934
-        dest[p] = s->current_picture.data[p] + ((mb_x << pixel_shift) + mb_y * s->linesize) * 16;
1934
+        dest[p] = s->current_picture.f.data[p] + ((mb_x << pixel_shift) + mb_y * s->linesize) * 16;
1935 1935
         s->dsp.prefetch(dest[p] + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4);
1936 1936
     }
1937 1937
 
... ...
@@ -2040,7 +2040,7 @@ static void av_noinline hl_decode_mb_444_simple(H264Context *h){
2040 2040
 void ff_h264_hl_decode_mb(H264Context *h){
2041 2041
     MpegEncContext * const s = &h->s;
2042 2042
     const int mb_xy= h->mb_xy;
2043
-    const int mb_type= s->current_picture.mb_type[mb_xy];
2043
+    const int mb_type = s->current_picture.f.mb_type[mb_xy];
2044 2044
     int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;
2045 2045
 
2046 2046
     if (CHROMA444) {
... ...
@@ -2194,14 +2194,14 @@ static void flush_dpb(AVCodecContext *avctx){
2194 2194
     int i;
2195 2195
     for(i=0; i<MAX_DELAYED_PIC_COUNT; i++) {
2196 2196
         if(h->delayed_pic[i])
2197
-            h->delayed_pic[i]->reference= 0;
2197
+            h->delayed_pic[i]->f.reference = 0;
2198 2198
         h->delayed_pic[i]= NULL;
2199 2199
     }
2200 2200
     h->outputed_poc=h->next_outputed_poc= INT_MIN;
2201 2201
     h->prev_interlaced_frame = 1;
2202 2202
     idr(h);
2203 2203
     if(h->s.current_picture_ptr)
2204
-        h->s.current_picture_ptr->reference= 0;
2204
+        h->s.current_picture_ptr->f.reference = 0;
2205 2205
     h->s.first_field= 0;
2206 2206
     ff_h264_reset_sei(h);
2207 2207
     ff_mpeg_flush(avctx);
... ...
@@ -2680,8 +2680,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
2680 2680
              * be fixed. */
2681 2681
             if (h->short_ref_count) {
2682 2682
                 if (prev) {
2683
-                    av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize,
2684
-                                  (const uint8_t**)prev->data, prev->linesize,
2683
+                    av_image_copy(h->short_ref[0]->f.data, h->short_ref[0]->f.linesize,
2684
+                                  (const uint8_t**)prev->f.data, prev->f.linesize,
2685 2685
                                   s->avctx->pix_fmt, s->mb_width*16, s->mb_height*16);
2686 2686
                     h->short_ref[0]->poc = prev->poc+2;
2687 2687
                 }
... ...
@@ -2692,7 +2692,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
2692 2692
         /* See if we have a decoded first field looking for a pair... */
2693 2693
         if (s0->first_field) {
2694 2694
             assert(s0->current_picture_ptr);
2695
-            assert(s0->current_picture_ptr->data[0]);
2695
+            assert(s0->current_picture_ptr->f.data[0]);
2696 2696
             assert(s0->current_picture_ptr->reference != DELAYED_PIC_REF);
2697 2697
 
2698 2698
             /* figure out if we have a complementary field pair */
... ...
@@ -2706,7 +2706,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
2706 2706
 
2707 2707
             } else {
2708 2708
                 if (h->nal_ref_idc &&
2709
-                        s0->current_picture_ptr->reference &&
2709
+                        s0->current_picture_ptr->f.reference &&
2710 2710
                         s0->current_picture_ptr->frame_num != h->frame_num) {
2711 2711
                     /*
2712 2712
                      * This and previous field were reference, but had
... ...
@@ -2954,16 +2954,16 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
2954 2954
         int *ref2frm= h->ref2frm[h->slice_num&(MAX_SLICES-1)][j];
2955 2955
         for(i=0; i<16; i++){
2956 2956
             id_list[i]= 60;
2957
-            if(h->ref_list[j][i].data[0]){
2957
+            if (h->ref_list[j][i].f.data[0]) {
2958 2958
                 int k;
2959
-                uint8_t *base= h->ref_list[j][i].base[0];
2959
+                uint8_t *base = h->ref_list[j][i].f.base[0];
2960 2960
                 for(k=0; k<h->short_ref_count; k++)
2961
-                    if(h->short_ref[k]->base[0] == base){
2961
+                    if (h->short_ref[k]->f.base[0] == base) {
2962 2962
                         id_list[i]= k;
2963 2963
                         break;
2964 2964
                     }
2965 2965
                 for(k=0; k<h->long_ref_count; k++)
2966
-                    if(h->long_ref[k] && h->long_ref[k]->base[0] == base){
2966
+                    if (h->long_ref[k] && h->long_ref[k]->f.base[0] == base) {
2967 2967
                         id_list[i]= h->short_ref_count + k;
2968 2968
                         break;
2969 2969
                     }
... ...
@@ -2974,12 +2974,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
2974 2974
         ref2frm[1]= -1;
2975 2975
         for(i=0; i<16; i++)
2976 2976
             ref2frm[i+2]= 4*id_list[i]
2977
-                          +(h->ref_list[j][i].reference&3);
2977
+                          + (h->ref_list[j][i].f.reference & 3);
2978 2978
         ref2frm[18+0]=
2979 2979
         ref2frm[18+1]= -1;
2980 2980
         for(i=16; i<48; i++)
2981 2981
             ref2frm[i+4]= 4*id_list[(i-16)>>1]
2982
-                          +(h->ref_list[j][i].reference&3);
2982
+                          + (h->ref_list[j][i].f.reference & 3);
2983 2983
     }
2984 2984
 
2985 2985
     //FIXME: fix draw_edges+PAFF+frame threads
... ...
@@ -3029,11 +3029,11 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon
3029 3029
             const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride;
3030 3030
             const int b8_xy= 4*top_xy + 2;
3031 3031
             int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
3032
-            AV_COPY128(mv_dst - 1*8, s->current_picture.motion_val[list][b_xy + 0]);
3032
+            AV_COPY128(mv_dst - 1*8, s->current_picture.f.motion_val[list][b_xy + 0]);
3033 3033
             ref_cache[0 - 1*8]=
3034
-            ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 0]];
3034
+            ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 0]];
3035 3035
             ref_cache[2 - 1*8]=
3036
-            ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 1]];
3036
+            ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 1]];
3037 3037
         }else{
3038 3038
             AV_ZERO128(mv_dst - 1*8);
3039 3039
             AV_WN32A(&ref_cache[0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);
... ...
@@ -3044,14 +3044,14 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon
3044 3044
                 const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3;
3045 3045
                 const int b8_xy= 4*left_xy[LTOP] + 1;
3046 3046
                 int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[LTOP]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
3047
-                AV_COPY32(mv_dst - 1 + 0, s->current_picture.motion_val[list][b_xy + b_stride*0]);
3048
-                AV_COPY32(mv_dst - 1 + 8, s->current_picture.motion_val[list][b_xy + b_stride*1]);
3049
-                AV_COPY32(mv_dst - 1 +16, s->current_picture.motion_val[list][b_xy + b_stride*2]);
3050
-                AV_COPY32(mv_dst - 1 +24, s->current_picture.motion_val[list][b_xy + b_stride*3]);
3047
+                AV_COPY32(mv_dst - 1 +  0, s->current_picture.f.motion_val[list][b_xy + b_stride*0]);
3048
+                AV_COPY32(mv_dst - 1 +  8, s->current_picture.f.motion_val[list][b_xy + b_stride*1]);
3049
+                AV_COPY32(mv_dst - 1 + 16, s->current_picture.f.motion_val[list][b_xy + b_stride*2]);
3050
+                AV_COPY32(mv_dst - 1 + 24, s->current_picture.f.motion_val[list][b_xy + b_stride*3]);
3051 3051
                 ref_cache[-1 +  0]=
3052
-                ref_cache[-1 +  8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*0]];
3052
+                ref_cache[-1 +  8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*0]];
3053 3053
                 ref_cache[-1 + 16]=
3054
-                ref_cache[-1 + 24]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*1]];
3054
+                ref_cache[-1 + 24]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*1]];
3055 3055
             }else{
3056 3056
                 AV_ZERO32(mv_dst - 1 + 0);
3057 3057
                 AV_ZERO32(mv_dst - 1 + 8);
... ...
@@ -3075,7 +3075,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon
3075 3075
     }
3076 3076
 
3077 3077
     {
3078
-        int8_t *ref = &s->current_picture.ref_index[list][4*mb_xy];
3078
+        int8_t *ref = &s->current_picture.f.ref_index[list][4*mb_xy];
3079 3079
         int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
3080 3080
         uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101;
3081 3081
         uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]],ref2frm[list][ref[3]])&0x00FF00FF)*0x0101;
... ...
@@ -3086,7 +3086,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon
3086 3086
     }
3087 3087
 
3088 3088
     {
3089
-        int16_t (*mv_src)[2] = &s->current_picture.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride];
3089
+        int16_t (*mv_src)[2] = &s->current_picture.f.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride];
3090 3090
         AV_COPY128(mv_dst + 8*0, mv_src + 0*b_stride);
3091 3091
         AV_COPY128(mv_dst + 8*1, mv_src + 1*b_stride);
3092 3092
         AV_COPY128(mv_dst + 8*2, mv_src + 2*b_stride);
... ...
@@ -3113,7 +3113,7 @@ static int fill_filter_caches(H264Context *h, int mb_type){
3113 3113
 
3114 3114
     left_xy[LBOT] = left_xy[LTOP] = mb_xy-1;
3115 3115
     if(FRAME_MBAFF){
3116
-        const int left_mb_field_flag     = IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]);
3116
+        const int left_mb_field_flag     = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);
3117 3117
         const int curr_mb_field_flag     = IS_INTERLACED(mb_type);
3118 3118
         if(s->mb_y&1){
3119 3119
             if (left_mb_field_flag != curr_mb_field_flag) {
... ...
@@ -3121,7 +3121,7 @@ static int fill_filter_caches(H264Context *h, int mb_type){
3121 3121
             }
3122 3122
         }else{
3123 3123
             if(curr_mb_field_flag){
3124
-                top_xy      += s->mb_stride & (((s->current_picture.mb_type[top_xy    ]>>7)&1)-1);
3124
+                top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1);
3125 3125
             }
3126 3126
             if (left_mb_field_flag != curr_mb_field_flag) {
3127 3127
                 left_xy[LBOT] += s->mb_stride;
... ...
@@ -3136,21 +3136,21 @@ static int fill_filter_caches(H264Context *h, int mb_type){
3136 3136
         //for sufficiently low qp, filtering wouldn't do anything
3137 3137
         //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp
3138 3138
         int qp_thresh = h->qp_thresh; //FIXME strictly we should store qp_thresh for each mb of a slice
3139
-        int qp = s->current_picture.qscale_table[mb_xy];
3139
+        int qp = s->current_picture.f.qscale_table[mb_xy];
3140 3140
         if(qp <= qp_thresh
3141
-           && (left_xy[LTOP]<0 || ((qp + s->current_picture.qscale_table[left_xy[LTOP]] + 1)>>1) <= qp_thresh)
3142
-           && (top_xy       <0 || ((qp + s->current_picture.qscale_table[top_xy       ] + 1)>>1) <= qp_thresh)){
3141
+           && (left_xy[LTOP] < 0 || ((qp + s->current_picture.f.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh)
3142
+           && (top_xy        < 0 || ((qp + s->current_picture.f.qscale_table[top_xy       ] + 1) >> 1) <= qp_thresh)) {
3143 3143
             if(!FRAME_MBAFF)
3144 3144
                 return 1;
3145
-            if(   (left_xy[LTOP]< 0            || ((qp + s->current_picture.qscale_table[left_xy[LBOT]             ] + 1)>>1) <= qp_thresh)
3146
-               && (top_xy       < s->mb_stride || ((qp + s->current_picture.qscale_table[top_xy       -s->mb_stride] + 1)>>1) <= qp_thresh))
3145
+            if ((left_xy[LTOP] < 0            || ((qp + s->current_picture.f.qscale_table[left_xy[LBOT]        ] + 1) >> 1) <= qp_thresh) &&
3146
+                (top_xy        < s->mb_stride || ((qp + s->current_picture.f.qscale_table[top_xy - s->mb_stride] + 1) >> 1) <= qp_thresh))
3147 3147
                 return 1;
3148 3148
         }
3149 3149
     }
3150 3150
 
3151
-    top_type        = s->current_picture.mb_type[top_xy];
3152
-    left_type[LTOP] = s->current_picture.mb_type[left_xy[LTOP]];
3153
-    left_type[LBOT] = s->current_picture.mb_type[left_xy[LBOT]];
3151
+    top_type        = s->current_picture.f.mb_type[top_xy];
3152
+    left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];
3153
+    left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];
3154 3154
     if(h->deblocking_filter == 2){
3155 3155
         if(h->slice_table[top_xy       ] != h->slice_num) top_type= 0;
3156 3156
         if(h->slice_table[left_xy[LBOT]] != h->slice_num) left_type[LTOP]= left_type[LBOT]= 0;
... ...
@@ -3239,7 +3239,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x){
3239 3239
                 int mb_xy, mb_type;
3240 3240
                 mb_xy = h->mb_xy = mb_x + mb_y*s->mb_stride;
3241 3241
                 h->slice_num= h->slice_table[mb_xy];
3242
-                mb_type= s->current_picture.mb_type[mb_xy];
3242
+                mb_type = s->current_picture.f.mb_type[mb_xy];
3243 3243
                 h->list_count= h->list_counts[mb_xy];
3244 3244
 
3245 3245
                 if(FRAME_MBAFF)
... ...
@@ -3247,9 +3247,9 @@ static void loop_filter(H264Context *h, int start_x, int end_x){
3247 3247
 
3248 3248
                 s->mb_x= mb_x;
3249 3249
                 s->mb_y= mb_y;
3250
-                dest_y  = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize  ) * 16;
3251
-                dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
3252
-                dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
3250
+                dest_y  = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize  ) * 16;
3251
+                dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
3252
+                dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
3253 3253
                     //FIXME simplify above
3254 3254
 
3255 3255
                 if (MB_FIELD) {
... ...
@@ -3267,8 +3267,8 @@ static void loop_filter(H264Context *h, int start_x, int end_x){
3267 3267
                 backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, CHROMA444, 0);
3268 3268
                 if(fill_filter_caches(h, mb_type))
3269 3269
                     continue;
3270
-                h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.qscale_table[mb_xy]);
3271
-                h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.qscale_table[mb_xy]);
3270
+                h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mb_xy]);
3271
+                h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mb_xy]);
3272 3272
 
3273 3273
                 if (FRAME_MBAFF) {
3274 3274
                     ff_h264_filter_mb     (h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
... ...
@@ -3289,9 +3289,9 @@ static void predict_field_decoding_flag(H264Context *h){
3289 3289
     MpegEncContext * const s = &h->s;
3290 3290
     const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
3291 3291
     int mb_type = (h->slice_table[mb_xy-1] == h->slice_num)
3292
-                ? s->current_picture.mb_type[mb_xy-1]
3292
+                ? s->current_picture.f.mb_type[mb_xy - 1]
3293 3293
                 : (h->slice_table[mb_xy-s->mb_stride] == h->slice_num)
3294
-                ? s->current_picture.mb_type[mb_xy-s->mb_stride]
3294
+                ? s->current_picture.f.mb_type[mb_xy - s->mb_stride]
3295 3295
                 : 0;
3296 3296
     h->mb_mbaff = h->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0;
3297 3297
 }
... ...
@@ -3672,7 +3672,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
3672 3672
             if((err = decode_slice_header(hx, h)))
3673 3673
                break;
3674 3674
 
3675
-            s->current_picture_ptr->key_frame |=
3675
+            s->current_picture_ptr->f.key_frame |=
3676 3676
                     (hx->nal_unit_type == NAL_IDR_SLICE) ||
3677 3677
                     (h->sei_recovery_frame_cnt >= 0);
3678 3678
 
... ...
@@ -3836,7 +3836,7 @@ static int decode_frame(AVCodecContext *avctx,
3836 3836
 //FIXME factorize this with the output code below
3837 3837
         out = h->delayed_pic[0];
3838 3838
         out_idx = 0;
3839
-        for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++)
3839
+        for (i = 1; h->delayed_pic[i] && !h->delayed_pic[i]->f.key_frame && !h->delayed_pic[i]->mmco_reset; i++)
3840 3840
             if(h->delayed_pic[i]->poc < out->poc){
3841 3841
                 out = h->delayed_pic[i];
3842 3842
                 out_idx = i;
... ...
@@ -795,8 +795,8 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){
795 795
     left_xy[LBOT] = left_xy[LTOP] = mb_xy-1;
796 796
     h->left_block = left_block_options[0];
797 797
     if(FRAME_MBAFF){
798
-        const int left_mb_field_flag     = IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]);
799
-        const int curr_mb_field_flag     = IS_INTERLACED(mb_type);
798
+        const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);
799
+        const int curr_mb_field_flag = IS_INTERLACED(mb_type);
800 800
         if(s->mb_y&1){
801 801
             if (left_mb_field_flag != curr_mb_field_flag) {
802 802
                 left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1;
... ...
@@ -812,9 +812,9 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){
812 812
             }
813 813
         }else{
814 814
             if(curr_mb_field_flag){
815
-                topleft_xy  += s->mb_stride & (((s->current_picture.mb_type[top_xy - 1]>>7)&1)-1);
816
-                topright_xy += s->mb_stride & (((s->current_picture.mb_type[top_xy + 1]>>7)&1)-1);
817
-                top_xy      += s->mb_stride & (((s->current_picture.mb_type[top_xy    ]>>7)&1)-1);
815
+                topleft_xy  += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1);
816
+                topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1);
817
+                top_xy      += s->mb_stride & (((s->current_picture.f.mb_type[top_xy    ] >> 7) & 1) - 1);
818 818
             }
819 819
             if (left_mb_field_flag != curr_mb_field_flag) {
820 820
                 if (curr_mb_field_flag) {
... ...
@@ -834,11 +834,11 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){
834 834
     h->left_mb_xy[LBOT] = left_xy[LBOT];
835 835
     //FIXME do we need all in the context?
836 836
 
837
-    h->topleft_type = s->current_picture.mb_type[topleft_xy] ;
838
-    h->top_type     = s->current_picture.mb_type[top_xy]     ;
839
-    h->topright_type= s->current_picture.mb_type[topright_xy];
840
-    h->left_type[LTOP] = s->current_picture.mb_type[left_xy[LTOP]] ;
841
-    h->left_type[LBOT] = s->current_picture.mb_type[left_xy[LBOT]] ;
837
+    h->topleft_type    = s->current_picture.f.mb_type[topleft_xy];
838
+    h->top_type        = s->current_picture.f.mb_type[top_xy];
839
+    h->topright_type   = s->current_picture.f.mb_type[topright_xy];
840
+    h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];
841
+    h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];
842 842
 
843 843
     if(FMO){
844 844
     if(h->slice_table[topleft_xy    ] != h->slice_num) h->topleft_type = 0;
... ...
@@ -898,7 +898,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){
898 898
                         h->left_samples_available&= 0xFF5F;
899 899
                     }
900 900
                 }else{
901
-                    int left_typei = s->current_picture.mb_type[left_xy[LTOP] + s->mb_stride];
901
+                    int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride];
902 902
 
903 903
                     assert(left_xy[LTOP] == left_xy[LBOT]);
904 904
                     if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){
... ...
@@ -1016,9 +1016,9 @@ static void fill_decode_caches(H264Context *h, int mb_type){
1016 1016
         int b_stride = h->b_stride;
1017 1017
         for(list=0; list<h->list_count; list++){
1018 1018
             int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
1019
-            int8_t *ref = s->current_picture.ref_index[list];
1019
+            int8_t *ref       = s->current_picture.f.ref_index[list];
1020 1020
             int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]];
1021
-            int16_t (*mv)[2] = s->current_picture.motion_val[list];
1021
+            int16_t (*mv)[2]       = s->current_picture.f.motion_val[list];
1022 1022
             if(!USES_LIST(mb_type, list)){
1023 1023
                 continue;
1024 1024
             }
... ...
@@ -1240,7 +1240,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h){
1240 1240
 static av_always_inline void write_back_motion_list(H264Context *h, MpegEncContext * const s, int b_stride,
1241 1241
                                                     int b_xy, int b8_xy, int mb_type, int list )
1242 1242
 {
1243
-    int16_t (*mv_dst)[2] = &s->current_picture.motion_val[list][b_xy];
1243
+    int16_t (*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy];
1244 1244
     int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]];
1245 1245
     AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0);
1246 1246
     AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1);
... ...
@@ -1260,7 +1260,7 @@ static av_always_inline void write_back_motion_list(H264Context *h, MpegEncConte
1260 1260
     }
1261 1261
 
1262 1262
     {
1263
-        int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy];
1263
+        int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy];
1264 1264
         int8_t *ref_cache = h->ref_cache[list];
1265 1265
         ref_index[0+0*2]= ref_cache[scan8[0]];
1266 1266
         ref_index[1+0*2]= ref_cache[scan8[4]];
... ...
@@ -1278,7 +1278,8 @@ static av_always_inline void write_back_motion(H264Context *h, int mb_type){
1278 1278
     if(USES_LIST(mb_type, 0)){
1279 1279
         write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0);
1280 1280
     }else{
1281
-        fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
1281
+        fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy],
1282
+                       2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
1282 1283
     }
1283 1284
     if(USES_LIST(mb_type, 1)){
1284 1285
         write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1);
... ...
@@ -1334,8 +1335,8 @@ static void av_unused decode_mb_skip(H264Context *h){
1334 1334
     }
1335 1335
 
1336 1336
     write_back_motion(h, mb_type);
1337
-    s->current_picture.mb_type[mb_xy]= mb_type;
1338
-    s->current_picture.qscale_table[mb_xy]= s->qscale;
1337
+    s->current_picture.f.mb_type[mb_xy]      = mb_type;
1338
+    s->current_picture.f.qscale_table[mb_xy] = s->qscale;
1339 1339
     h->slice_table[ mb_xy ]= h->slice_num;
1340 1340
     h->prev_mb_skipped= 1;
1341 1341
 }
... ...
@@ -1284,8 +1284,8 @@ static int decode_cabac_field_decoding_flag(H264Context *h) {
1284 1284
 
1285 1285
     unsigned long ctx = 0;
1286 1286
 
1287
-    ctx += h->mb_field_decoding_flag & !!s->mb_x; //for FMO:(s->current_picture.mb_type[mba_xy]>>7)&(h->slice_table[mba_xy] == h->slice_num);
1288
-    ctx += (s->current_picture.mb_type[mbb_xy]>>7)&(h->slice_table[mbb_xy] == h->slice_num);
1287
+    ctx += h->mb_field_decoding_flag & !!s->mb_x; //for FMO:(s->current_picture.f.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num);
1288
+    ctx += (s->current_picture.f.mb_type[mbb_xy] >> 7) & (h->slice_table[mbb_xy] == h->slice_num);
1289 1289
 
1290 1290
     return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] );
1291 1291
 }
... ...
@@ -1330,13 +1330,13 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
1330 1330
         mba_xy = mb_xy - 1;
1331 1331
         if( (mb_y&1)
1332 1332
             && h->slice_table[mba_xy] == h->slice_num
1333
-            && MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[mba_xy] ) )
1333
+            && MB_FIELD == !!IS_INTERLACED( s->current_picture.f.mb_type[mba_xy] ) )
1334 1334
             mba_xy += s->mb_stride;
1335 1335
         if( MB_FIELD ){
1336 1336
             mbb_xy = mb_xy - s->mb_stride;
1337 1337
             if( !(mb_y&1)
1338 1338
                 && h->slice_table[mbb_xy] == h->slice_num
1339
-                && IS_INTERLACED( s->current_picture.mb_type[mbb_xy] ) )
1339
+                && IS_INTERLACED( s->current_picture.f.mb_type[mbb_xy] ) )
1340 1340
                 mbb_xy -= s->mb_stride;
1341 1341
         }else
1342 1342
             mbb_xy = mb_x + (mb_y-1)*s->mb_stride;
... ...
@@ -1346,9 +1346,9 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
1346 1346
         mbb_xy = mb_xy - (s->mb_stride << FIELD_PICTURE);
1347 1347
     }
1348 1348
 
1349
-    if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ))
1349
+    if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.f.mb_type[mba_xy] ))
1350 1350
         ctx++;
1351
-    if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ))
1351
+    if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.f.mb_type[mbb_xy] ))
1352 1352
         ctx++;
1353 1353
 
1354 1354
     if( h->slice_type_nos == AV_PICTURE_TYPE_B )
... ...
@@ -1850,7 +1850,7 @@ int ff_h264_decode_mb_cabac(H264Context *h) {
1850 1850
         /* read skip flags */
1851 1851
         if( skip ) {
1852 1852
             if( FRAME_MBAFF && (s->mb_y&1)==0 ){
1853
-                s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP;
1853
+                s->current_picture.f.mb_type[mb_xy] = MB_TYPE_SKIP;
1854 1854
                 h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
1855 1855
                 if(!h->next_mb_skipped)
1856 1856
                     h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
... ...
@@ -1966,10 +1966,10 @@ decode_intra_mb:
1966 1966
         h->cbp_table[mb_xy] = 0xf7ef;
1967 1967
         h->chroma_pred_mode_table[mb_xy] = 0;
1968 1968
         // In deblocking, the quantizer is 0
1969
-        s->current_picture.qscale_table[mb_xy]= 0;
1969
+        s->current_picture.f.qscale_table[mb_xy] = 0;
1970 1970
         // All coeffs are present
1971 1971
         memset(h->non_zero_count[mb_xy], 16, 48);
1972
-        s->current_picture.mb_type[mb_xy]= mb_type;
1972
+        s->current_picture.f.mb_type[mb_xy] = mb_type;
1973 1973
         h->last_qscale_diff = 0;
1974 1974
         return 0;
1975 1975
     }
... ...
@@ -2266,7 +2266,7 @@ decode_intra_mb:
2266 2266
             AV_WN32A(&nnz_cache[4+8*10], top_empty);
2267 2267
         }
2268 2268
     }
2269
-    s->current_picture.mb_type[mb_xy]= mb_type;
2269
+    s->current_picture.f.mb_type[mb_xy] = mb_type;
2270 2270
 
2271 2271
     if( cbp || IS_INTRA16x16( mb_type ) ) {
2272 2272
         const uint8_t *scan, *scan8x8;
... ...
@@ -2345,7 +2345,7 @@ decode_intra_mb:
2345 2345
         h->last_qscale_diff = 0;
2346 2346
     }
2347 2347
 
2348
-    s->current_picture.qscale_table[mb_xy]= s->qscale;
2348
+    s->current_picture.f.qscale_table[mb_xy] = s->qscale;
2349 2349
     write_back_non_zero_count(h);
2350 2350
 
2351 2351
     if(MB_MBAFF){
... ...
@@ -689,11 +689,11 @@ decode_intra_mb:
689 689
         }
690 690
 
691 691
         // In deblocking, the quantizer is 0
692
-        s->current_picture.qscale_table[mb_xy]= 0;
692
+        s->current_picture.f.qscale_table[mb_xy] = 0;
693 693
         // All coeffs are present
694 694
         memset(h->non_zero_count[mb_xy], 16, 48);
695 695
 
696
-        s->current_picture.mb_type[mb_xy]= mb_type;
696
+        s->current_picture.f.mb_type[mb_xy] = mb_type;
697 697
         return 0;
698 698
     }
699 699
 
... ...
@@ -990,7 +990,7 @@ decode_intra_mb:
990 990
     }
991 991
     h->cbp=
992 992
     h->cbp_table[mb_xy]= cbp;
993
-    s->current_picture.mb_type[mb_xy]= mb_type;
993
+    s->current_picture.f.mb_type[mb_xy] = mb_type;
994 994
 
995 995
     if(cbp || IS_INTRA16x16(mb_type)){
996 996
         int i4x4, chroma_idx;
... ...
@@ -1063,7 +1063,7 @@ decode_intra_mb:
1063 1063
         fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
1064 1064
         fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
1065 1065
     }
1066
-    s->current_picture.qscale_table[mb_xy]= s->qscale;
1066
+    s->current_picture.f.qscale_table[mb_xy] = s->qscale;
1067 1067
     write_back_non_zero_count(h);
1068 1068
 
1069 1069
     if(MB_MBAFF){
... ...
@@ -87,7 +87,7 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field,
87 87
                 poc= (poc&~3) + rfield + 1;
88 88
 
89 89
             for(j=start; j<end; j++){
90
-                if(4*h->ref_list[0][j].frame_num + (h->ref_list[0][j].reference&3) == poc){
90
+                if (4 * h->ref_list[0][j].frame_num + (h->ref_list[0][j].f.reference & 3) == poc) {
91 91
                     int cur_ref= mbafi ? (j-16)^field : j;
92 92
                     map[list][2*old_ref + (rfield^field) + 16] = cur_ref;
93 93
                     if(rfield == field || !interl)
... ...
@@ -105,12 +105,12 @@ void ff_h264_direct_ref_list_init(H264Context * const h){
105 105
     Picture * const cur = s->current_picture_ptr;
106 106
     int list, j, field;
107 107
     int sidx= (s->picture_structure&1)^1;
108
-    int ref1sidx= (ref1->reference&1)^1;
108
+    int ref1sidx = (ref1->f.reference&1)^1;
109 109
 
110 110
     for(list=0; list<2; list++){
111 111
         cur->ref_count[sidx][list] = h->ref_count[list];
112 112
         for(j=0; j<h->ref_count[list]; j++)
113
-            cur->ref_poc[sidx][list][j] = 4*h->ref_list[list][j].frame_num + (h->ref_list[list][j].reference&3);
113
+            cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3);
114 114
     }
115 115
 
116 116
     if(s->picture_structure == PICT_FRAME){
... ...
@@ -126,11 +126,11 @@ void ff_h264_direct_ref_list_init(H264Context * const h){
126 126
         int *col_poc = h->ref_list[1]->field_poc;
127 127
         h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc));
128 128
         ref1sidx=sidx= h->col_parity;
129
-    }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){ // FL -> FL & differ parity
130
-        h->col_fieldoff= 2*(h->ref_list[1][0].reference) - 3;
129
+    } else if (!(s->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { // FL -> FL & differ parity
130
+        h->col_fieldoff = 2 * h->ref_list[1][0].f.reference - 3;
131 131
     }
132 132
 
133
-    if(cur->pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)
133
+    if (cur->f.pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)
134 134
         return;
135 135
 
136 136
     for(list=0; list<2; list++){
... ...
@@ -143,7 +143,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){
143 143
 
144 144
 static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y)
145 145
 {
146
-    int ref_field = ref->reference - 1;
146
+    int ref_field = ref->f.reference - 1;
147 147
     int ref_field_picture = ref->field_picture;
148 148
     int ref_height = 16*h->s.mb_height >> ref_field_picture;
149 149
 
... ...
@@ -234,8 +234,8 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
234 234
         return;
235 235
     }
236 236
 
237
-    if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL
238
-        if(!IS_INTERLACED(*mb_type)){                    //     AFR/FR    -> AFL/FL
237
+    if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
238
+        if (!IS_INTERLACED(*mb_type)) {                          //     AFR/FR    -> AFL/FL
239 239
             mb_y = (s->mb_y&~1) + h->col_parity;
240 240
             mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
241 241
             b8_stride = 0;
... ...
@@ -248,8 +248,8 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
248 248
         if(IS_INTERLACED(*mb_type)){                     // AFL       /FL -> AFR/FR
249 249
             mb_y = s->mb_y&~1;
250 250
             mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
251
-            mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy];
252
-            mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride];
251
+            mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
252
+            mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride];
253 253
             b8_stride = 2+4*s->mb_stride;
254 254
             b4_stride *= 6;
255 255
 
... ...
@@ -264,7 +264,7 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
264 264
         }else{                                           //     AFR/FR    -> AFR/FR
265 265
 single_col:
266 266
             mb_type_col[0] =
267
-            mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy];
267
+            mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy];
268 268
 
269 269
             sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
270 270
             if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
... ...
@@ -284,10 +284,10 @@ single_col:
284 284
 
285 285
     await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
286 286
 
287
-    l1mv0  = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]];
288
-    l1mv1  = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]];
289
-    l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy];
290
-    l1ref1 = &h->ref_list[1][0].ref_index [1][4*mb_xy];
287
+    l1mv0  = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]];
288
+    l1mv1  = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]];
289
+    l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
290
+    l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
291 291
     if(!b8_stride){
292 292
         if(s->mb_y&1){
293 293
             l1ref0 += 2;
... ...
@@ -420,8 +420,8 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
420 420
 
421 421
     await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type));
422 422
 
423
-    if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL
424
-        if(!IS_INTERLACED(*mb_type)){                    //     AFR/FR    -> AFL/FL
423
+    if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
424
+        if (!IS_INTERLACED(*mb_type)) {                          //     AFR/FR    -> AFL/FL
425 425
             mb_y = (s->mb_y&~1) + h->col_parity;
426 426
             mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
427 427
             b8_stride = 0;
... ...
@@ -434,8 +434,8 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
434 434
         if(IS_INTERLACED(*mb_type)){                     // AFL       /FL -> AFR/FR
435 435
             mb_y = s->mb_y&~1;
436 436
             mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
437
-            mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy];
438
-            mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride];
437
+            mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
438
+            mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride];
439 439
             b8_stride = 2+4*s->mb_stride;
440 440
             b4_stride *= 6;
441 441
 
... ...
@@ -451,7 +451,7 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
451 451
         }else{                                           //     AFR/FR    -> AFR/FR
452 452
 single_col:
453 453
             mb_type_col[0] =
454
-            mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy];
454
+            mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy];
455 455
 
456 456
             sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
457 457
             if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
... ...
@@ -471,10 +471,10 @@ single_col:
471 471
 
472 472
     await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
473 473
 
474
-    l1mv0  = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]];
475
-    l1mv1  = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]];
476
-    l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy];
477
-    l1ref1 = &h->ref_list[1][0].ref_index [1][4*mb_xy];
474
+    l1mv0  = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]];
475
+    l1mv1  = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]];
476
+    l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
477
+    l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
478 478
     if(!b8_stride){
479 479
         if(s->mb_y&1){
480 480
             l1ref0 += 2;
... ...
@@ -100,14 +100,14 @@ static const uint8_t tc0_table[52*3][4] = {
100 100
     {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
101 101
 };
102 102
 
103
-static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h) {
104
-    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
105
-    const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
103
+/* intra: 0 if this loopfilter call is guaranteed to be inter (bS < 4), 1 if it might be intra (bS == 4) */
104
+static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
105
+    const unsigned int index_a = qp + a;
106 106
     const int alpha = alpha_table[index_a];
107
-    const int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
107
+    const int beta  = beta_table[qp + b];
108 108
     if (alpha ==0 || beta == 0) return;
109 109
 
110
-    if( bS[0] < 4 ) {
110
+    if( bS[0] < 4 || !intra ) {
111 111
         int8_t tc[4];
112 112
         tc[0] = tc0_table[index_a][bS[0]];
113 113
         tc[1] = tc0_table[index_a][bS[1]];
... ...
@@ -118,14 +118,13 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const in
118 118
         h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
119 119
     }
120 120
 }
121
-static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
122
-    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
123
-    const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
121
+static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
122
+    const unsigned int index_a = qp + a;
124 123
     const int alpha = alpha_table[index_a];
125
-    const int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
124
+    const int beta  = beta_table[qp + b];
126 125
     if (alpha ==0 || beta == 0) return;
127 126
 
128
-    if( bS[0] < 4 ) {
127
+    if( bS[0] < 4 || !intra ) {
129 128
         int8_t tc[4];
130 129
         tc[0] = tc0_table[index_a][bS[0]]+1;
131 130
         tc[1] = tc0_table[index_a][bS[1]]+1;
... ...
@@ -137,14 +136,13 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const i
137 137
     }
138 138
 }
139 139
 
140
-static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) {
141
-    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
142
-    int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
143
-    int alpha = alpha_table[index_a];
144
-    int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
140
+static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) {
141
+    const unsigned int index_a = qp + a;
142
+    const int alpha = alpha_table[index_a];
143
+    const int beta  = beta_table[qp + b];
145 144
     if (alpha ==0 || beta == 0) return;
146 145
 
147
-    if( bS[0] < 4 ) {
146
+    if( bS[0] < 4 || !intra ) {
148 147
         int8_t tc[4];
149 148
         tc[0] = tc0_table[index_a][bS[0*bsi]];
150 149
         tc[1] = tc0_table[index_a][bS[1*bsi]];
... ...
@@ -155,14 +153,13 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, con
155 155
         h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
156 156
     }
157 157
 }
158
-static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) {
159
-    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
160
-    int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
161
-    int alpha = alpha_table[index_a];
162
-    int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
158
+static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) {
159
+    const unsigned int index_a = qp + a;
160
+    const int alpha = alpha_table[index_a];
161
+    const int beta  = beta_table[qp + b];
163 162
     if (alpha ==0 || beta == 0) return;
164 163
 
165
-    if( bS[0] < 4 ) {
164
+    if( bS[0] < 4 || !intra ) {
166 165
         int8_t tc[4];
167 166
         tc[0] = tc0_table[index_a][bS[0*bsi]] + 1;
168 167
         tc[1] = tc0_table[index_a][bS[1*bsi]] + 1;
... ...
@@ -174,14 +171,13 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, co
174 174
     }
175 175
 }
176 176
 
177
-static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
178
-    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
179
-    const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
177
+static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
178
+    const unsigned int index_a = qp + a;
180 179
     const int alpha = alpha_table[index_a];
181
-    const int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
180
+    const int beta  = beta_table[qp + b];
182 181
     if (alpha ==0 || beta == 0) return;
183 182
 
184
-    if( bS[0] < 4 ) {
183
+    if( bS[0] < 4 || !intra ) {
185 184
         int8_t tc[4];
186 185
         tc[0] = tc0_table[index_a][bS[0]];
187 186
         tc[1] = tc0_table[index_a][bS[1]];
... ...
@@ -193,14 +189,13 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const in
193 193
     }
194 194
 }
195 195
 
196
-static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
197
-    const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
198
-    const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
196
+static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
197
+    const unsigned int index_a = qp + a;
199 198
     const int alpha = alpha_table[index_a];
200
-    const int beta  = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
199
+    const int beta  = beta_table[qp + b];
201 200
     if (alpha ==0 || beta == 0) return;
202 201
 
203
-    if( bS[0] < 4 ) {
202
+    if( bS[0] < 4 || !intra ) {
204 203
         int8_t tc[4];
205 204
         tc[0] = tc0_table[index_a][bS[0]]+1;
206 205
         tc[1] = tc0_table[index_a][bS[1]]+1;
... ...
@@ -212,31 +207,27 @@ static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const i
212 212
     }
213 213
 }
214 214
 
215
-void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
215
+static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
216
+                                                           unsigned int linesize, unsigned int uvlinesize, int pixel_shift) {
216 217
     MpegEncContext * const s = &h->s;
217
-    int mb_xy;
218
-    int mb_type, left_type, top_type;
219
-    int qp, qp0, qp1, qpc, qpc0, qpc1;
220 218
     int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
221 219
     int chroma444 = CHROMA444;
222 220
 
223
-    mb_xy = h->mb_xy;
224
-
225
-    if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {
226
-        ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
227
-        return;
228
-    }
229
-    assert(!FRAME_MBAFF);
230
-    left_type= h->left_type[LTOP];
231
-    top_type= h->top_type;
232
-
233
-    mb_type = s->current_picture.mb_type[mb_xy];
234
-    qp = s->current_picture.qscale_table[mb_xy];
235
-    qp0 = s->current_picture.qscale_table[mb_xy-1];
236
-    qp1 = s->current_picture.qscale_table[h->top_mb_xy];
237
-    qpc = get_chroma_qp( h, 0, qp );
238
-    qpc0 = get_chroma_qp( h, 0, qp0 );
239
-    qpc1 = get_chroma_qp( h, 0, qp1 );
221
+    int mb_xy = h->mb_xy;
222
+    int left_type= h->left_type[LTOP];
223
+    int top_type= h->top_type;
224
+
225
+    int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
226
+    int a = h->slice_alpha_c0_offset - qp_bd_offset;
227
+    int b = h->slice_beta_offset - qp_bd_offset;
228
+
229
+    int mb_type = s->current_picture.f.mb_type[mb_xy];
230
+    int qp      = s->current_picture.f.qscale_table[mb_xy];
231
+    int qp0     = s->current_picture.f.qscale_table[mb_xy - 1];
232
+    int qp1     = s->current_picture.f.qscale_table[h->top_mb_xy];
233
+    int qpc = get_chroma_qp( h, 0, qp );
234
+    int qpc0 = get_chroma_qp( h, 0, qp0 );
235
+    int qpc1 = get_chroma_qp( h, 0, qp1 );
240 236
     qp0 = (qp + qp0 + 1) >> 1;
241 237
     qp1 = (qp + qp1 + 1) >> 1;
242 238
     qpc0 = (qpc + qpc0 + 1) >> 1;
... ...
@@ -247,70 +238,70 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
247 247
         static const int16_t bS3[4] = {3,3,3,3};
248 248
         const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
249 249
         if(left_type)
250
-            filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h);
250
+            filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1);
251 251
         if( IS_8x8DCT(mb_type) ) {
252
-            filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h);
252
+            filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
253 253
             if(top_type){
254
-                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);
254
+                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
255 255
             }
256
-            filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);
256
+            filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
257 257
         } else {
258
-            filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h);
259
-            filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h);
260
-            filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h);
258
+            filter_mb_edgev( &img_y[4*1<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
259
+            filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
260
+            filter_mb_edgev( &img_y[4*3<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
261 261
             if(top_type){
262
-                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);
262
+                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
263 263
             }
264
-            filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h);
265
-            filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);
266
-            filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h);
264
+            filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, a, b, h, 0);
265
+            filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
266
+            filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, a, b, h, 0);
267 267
         }
268 268
         if(chroma){
269 269
             if(chroma444){
270 270
                 if(left_type){
271
-                    filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, h);
272
-                    filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, h);
271
+                    filter_mb_edgev( &img_cb[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
272
+                    filter_mb_edgev( &img_cr[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
273 273
                 }
274 274
                 if( IS_8x8DCT(mb_type) ) {
275
-                    filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h);
276
-                    filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h);
275
+                    filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
276
+                    filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
277 277
                     if(top_type){
278
-                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);
279
-                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);
278
+                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
279
+                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
280 280
                     }
281
-                    filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h);
282
-                    filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h);
281
+                    filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
282
+                    filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
283 283
                 } else {
284
-                    filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, h);
285
-                    filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, h);
286
-                    filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h);
287
-                    filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h);
288
-                    filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h);
289
-                    filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h);
284
+                    filter_mb_edgev( &img_cb[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
285
+                    filter_mb_edgev( &img_cr[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
286
+                    filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
287
+                    filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
288
+                    filter_mb_edgev( &img_cb[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
289
+                    filter_mb_edgev( &img_cr[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
290 290
                     if(top_type){
291
-                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);
292
-                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);
291
+                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
292
+                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
293 293
                     }
294
-                    filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h);
295
-                    filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h);
296
-                    filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h);
297
-                    filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h);
298
-                    filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, h);
299
-                    filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, h);
294
+                    filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
295
+                    filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
296
+                    filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
297
+                    filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
298
+                    filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
299
+                    filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
300 300
                 }
301 301
             }else{
302 302
                 if(left_type){
303
-                    filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h);
304
-                    filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h);
303
+                    filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
304
+                    filter_mb_edgecv( &img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
305 305
                 }
306
-                filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h);
307
-                filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h);
306
+                filter_mb_edgecv( &img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
307
+                filter_mb_edgecv( &img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
308 308
                 if(top_type){
309
-                    filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);
310
-                    filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);
309
+                    filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
310
+                    filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
311 311
                 }
312
-                filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h);
313
-                filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h);
312
+                filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
313
+                filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
314 314
             }
315 315
         }
316 316
         return;
... ...
@@ -336,43 +327,61 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
336 336
         if( IS_INTRA(top_type) )
337 337
             AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);
338 338
 
339
-#define FILTER(hv,dir,edge)\
339
+#define FILTER(hv,dir,edge,intra)\
340 340
         if(AV_RN64A(bS[dir][edge])) {                                   \
341
-            filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, h );\
341
+            filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qp : qp##dir, a, b, h, intra );\
342 342
             if(chroma){\
343 343
                 if(chroma444){\
344
-                    filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\
345
-                    filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\
344
+                    filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
345
+                    filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
346 346
                 } else if(!(edge&1)) {\
347
-                    filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\
348
-                    filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\
347
+                    filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
348
+                    filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
349 349
                 }\
350 350
             }\
351 351
         }
352 352
         if(left_type)
353
-            FILTER(v,0,0);
353
+            FILTER(v,0,0,1);
354 354
         if( edges == 1 ) {
355 355
             if(top_type)
356
-                FILTER(h,1,0);
356
+                FILTER(h,1,0,1);
357 357
         } else if( IS_8x8DCT(mb_type) ) {
358
-            FILTER(v,0,2);
358
+            FILTER(v,0,2,0);
359 359
             if(top_type)
360
-                FILTER(h,1,0);
361
-            FILTER(h,1,2);
360
+                FILTER(h,1,0,1);
361
+            FILTER(h,1,2,0);
362 362
         } else {
363
-            FILTER(v,0,1);
364
-            FILTER(v,0,2);
365
-            FILTER(v,0,3);
363
+            FILTER(v,0,1,0);
364
+            FILTER(v,0,2,0);
365
+            FILTER(v,0,3,0);
366 366
             if(top_type)
367
-                FILTER(h,1,0);
368
-            FILTER(h,1,1);
369
-            FILTER(h,1,2);
370
-            FILTER(h,1,3);
367
+                FILTER(h,1,0,1);
368
+            FILTER(h,1,1,0);
369
+            FILTER(h,1,2,0);
370
+            FILTER(h,1,3,0);
371 371
         }
372 372
 #undef FILTER
373 373
     }
374 374
 }
375 375
 
376
+void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
377
+    assert(!FRAME_MBAFF);
378
+    if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {
379
+        ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
380
+        return;
381
+    }
382
+
383
+#if CONFIG_SMALL
384
+    h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, h->pixel_shift);
385
+#else
386
+    if(h->pixel_shift){
387
+        h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 1);
388
+    }else{
389
+        h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 0);
390
+    }
391
+#endif
392
+}
393
+
376 394
 static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){
377 395
     int v;
378 396
 
... ...
@@ -402,7 +411,7 @@ static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){
402 402
     return v;
403 403
 }
404 404
 
405
-static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int chroma, int chroma444, int dir) {
405
+static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int a, int b, int chroma, int chroma444, int dir) {
406 406
     MpegEncContext * const s = &h->s;
407 407
     int edge;
408 408
     int chroma_qp_avg[2];
... ...
@@ -435,10 +444,10 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u
435 435
             for(j=0; j<2; j++, mbn_xy += s->mb_stride){
436 436
                 DECLARE_ALIGNED(8, int16_t, bS)[4];
437 437
                 int qp;
438
-                if( IS_INTRA(mb_type|s->current_picture.mb_type[mbn_xy]) ) {
438
+                if (IS_INTRA(mb_type | s->current_picture.f.mb_type[mbn_xy])) {
439 439
                     AV_WN64A(bS, 0x0003000300030003ULL);
440 440
                 } else {
441
-                    if(!CABAC && IS_8x8DCT(s->current_picture.mb_type[mbn_xy])){
441
+                    if (!CABAC && IS_8x8DCT(s->current_picture.f.mb_type[mbn_xy])) {
442 442
                         bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]);
443 443
                         bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]);
444 444
                         bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]);
... ...
@@ -453,19 +462,19 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u
453 453
                 }
454 454
                 // Do not use s->qscale as luma quantizer because it has not the same
455 455
                 // value in IPCM macroblocks.
456
-                qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
456
+                qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbn_xy] + 1) >> 1;
457 457
                 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
458 458
                 { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
459
-                filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, h );
460
-                chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
461
-                chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
459
+                filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, a, b, h, 0 );
460
+                chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1;
461
+                chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1;
462 462
                 if (chroma) {
463 463
                     if (chroma444) {
464
-                        filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h);
465
-                        filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h);
464
+                        filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
465
+                        filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0);
466 466
                     } else {
467
-                        filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h);
468
-                        filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h);
467
+                        filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
468
+                        filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0);
469 469
                     }
470 470
                 }
471 471
             }
... ...
@@ -518,32 +527,32 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u
518 518
             // Do not use s->qscale as luma quantizer because it has not the same
519 519
             // value in IPCM macroblocks.
520 520
             if(bS[0]+bS[1]+bS[2]+bS[3]){
521
-                qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbm_xy] + 1 ) >> 1;
521
+                qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbm_xy] + 1) >> 1;
522 522
                 //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]);
523 523
                 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
524 524
                 //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
525
-                chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1;
526
-                chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1;
525
+                chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1;
526
+                chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1;
527 527
                 if( dir == 0 ) {
528
-                    filter_mb_edgev( &img_y[0], linesize, bS, qp, h );
528
+                    filter_mb_edgev( &img_y[0], linesize, bS, qp, a, b, h, 1 );
529 529
                     if (chroma) {
530 530
                         if (chroma444) {
531
-                            filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h);
532
-                            filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h);
531
+                            filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
532
+                            filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
533 533
                         } else {
534
-                            filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h);
535
-                            filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h);
534
+                            filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
535
+                            filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
536 536
                         }
537 537
                     }
538 538
                 } else {
539
-                    filter_mb_edgeh( &img_y[0], linesize, bS, qp, h );
539
+                    filter_mb_edgeh( &img_y[0], linesize, bS, qp, a, b, h, 1 );
540 540
                     if (chroma) {
541 541
                         if (chroma444) {
542
-                            filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h);
543
-                            filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h);
542
+                            filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
543
+                            filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
544 544
                         } else {
545
-                            filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h);
546
-                            filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h);
545
+                            filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
546
+                            filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
547 547
                         }
548 548
                     }
549 549
                 }
... ...
@@ -602,30 +611,30 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u
602 602
         /* Filter edge */
603 603
         // Do not use s->qscale as luma quantizer because it has not the same
604 604
         // value in IPCM macroblocks.
605
-        qp = s->current_picture.qscale_table[mb_xy];
605
+        qp = s->current_picture.f.qscale_table[mb_xy];
606 606
         //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]);
607 607
         tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
608 608
         //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
609 609
         if( dir == 0 ) {
610
-            filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, h );
610
+            filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, a, b, h, 0 );
611 611
             if (chroma) {
612 612
                 if (chroma444) {
613
-                    filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h);
614
-                    filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h);
613
+                    filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
614
+                    filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
615 615
                 } else if( (edge&1) == 0 ) {
616
-                    filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h);
617
-                    filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h);
616
+                    filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
617
+                    filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
618 618
                 }
619 619
             }
620 620
         } else {
621
-            filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h );
621
+            filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0 );
622 622
             if (chroma) {
623 623
                 if (chroma444) {
624
-                    filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h);
625
-                    filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h);
624
+                    filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
625
+                    filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
626 626
                 } else if( (edge&1) == 0 ) {
627
-                    filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h);
628
-                    filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h);
627
+                    filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
628
+                    filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
629 629
                 }
630 630
             }
631 631
         }
... ...
@@ -635,11 +644,14 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u
635 635
 void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
636 636
     MpegEncContext * const s = &h->s;
637 637
     const int mb_xy= mb_x + mb_y*s->mb_stride;
638
-    const int mb_type = s->current_picture.mb_type[mb_xy];
638
+    const int mb_type = s->current_picture.f.mb_type[mb_xy];
639 639
     const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
640 640
     int first_vertical_edge_done = 0;
641 641
     av_unused int dir;
642 642
     int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
643
+    int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
644
+    int a = h->slice_alpha_c0_offset - qp_bd_offset;
645
+    int b = h->slice_beta_offset - qp_bd_offset;
643 646
 
644 647
     if (FRAME_MBAFF
645 648
             // and current and left pair do not have the same interlaced type
... ...
@@ -688,9 +700,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
688 688
             }
689 689
         }
690 690
 
691
-        mb_qp = s->current_picture.qscale_table[mb_xy];
692
-        mbn0_qp = s->current_picture.qscale_table[h->left_mb_xy[0]];
693
-        mbn1_qp = s->current_picture.qscale_table[h->left_mb_xy[1]];
691
+        mb_qp   = s->current_picture.f.qscale_table[mb_xy];
692
+        mbn0_qp = s->current_picture.f.qscale_table[h->left_mb_xy[0]];
693
+        mbn1_qp = s->current_picture.f.qscale_table[h->left_mb_xy[1]];
694 694
         qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
695 695
         bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
696 696
                    get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
... ...
@@ -706,35 +718,35 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
706 706
         tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
707 707
         { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
708 708
         if(MB_FIELD){
709
-            filter_mb_mbaff_edgev ( h, img_y                ,   linesize, bS  , 1, qp [0] );
710
-            filter_mb_mbaff_edgev ( h, img_y  + 8*  linesize,   linesize, bS+4, 1, qp [1] );
709
+            filter_mb_mbaff_edgev ( h, img_y                ,   linesize, bS  , 1, qp [0], a, b, 1 );
710
+            filter_mb_mbaff_edgev ( h, img_y  + 8*  linesize,   linesize, bS+4, 1, qp [1], a, b, 1 );
711 711
             if (chroma){
712 712
                 if (CHROMA444) {
713
-                    filter_mb_mbaff_edgev ( h, img_cb,                uvlinesize, bS  , 1, bqp[0] );
714
-                    filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1] );
715
-                    filter_mb_mbaff_edgev ( h, img_cr,                uvlinesize, bS  , 1, rqp[0] );
716
-                    filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1] );
713
+                    filter_mb_mbaff_edgev ( h, img_cb,                uvlinesize, bS  , 1, bqp[0], a, b, 1 );
714
+                    filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
715
+                    filter_mb_mbaff_edgev ( h, img_cr,                uvlinesize, bS  , 1, rqp[0], a, b, 1 );
716
+                    filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
717 717
                 }else{
718
-                    filter_mb_mbaff_edgecv( h, img_cb,                uvlinesize, bS  , 1, bqp[0] );
719
-                    filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1] );
720
-                    filter_mb_mbaff_edgecv( h, img_cr,                uvlinesize, bS  , 1, rqp[0] );
721
-                    filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1] );
718
+                    filter_mb_mbaff_edgecv( h, img_cb,                uvlinesize, bS  , 1, bqp[0], a, b, 1 );
719
+                    filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
720
+                    filter_mb_mbaff_edgecv( h, img_cr,                uvlinesize, bS  , 1, rqp[0], a, b, 1 );
721
+                    filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
722 722
                 }
723 723
             }
724 724
         }else{
725
-            filter_mb_mbaff_edgev ( h, img_y              , 2*  linesize, bS  , 2, qp [0] );
726
-            filter_mb_mbaff_edgev ( h, img_y  +   linesize, 2*  linesize, bS+1, 2, qp [1] );
725
+            filter_mb_mbaff_edgev ( h, img_y              , 2*  linesize, bS  , 2, qp [0], a, b, 1 );
726
+            filter_mb_mbaff_edgev ( h, img_y  +   linesize, 2*  linesize, bS+1, 2, qp [1], a, b, 1 );
727 727
             if (chroma){
728 728
                 if (CHROMA444) {
729
-                    filter_mb_mbaff_edgev ( h, img_cb,              2*uvlinesize, bS  , 2, bqp[0] );
730
-                    filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] );
731
-                    filter_mb_mbaff_edgev ( h, img_cr,              2*uvlinesize, bS  , 2, rqp[0] );
732
-                    filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] );
729
+                    filter_mb_mbaff_edgev ( h, img_cb,              2*uvlinesize, bS  , 2, bqp[0], a, b, 1 );
730
+                    filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
731
+                    filter_mb_mbaff_edgev ( h, img_cr,              2*uvlinesize, bS  , 2, rqp[0], a, b, 1 );
732
+                    filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
733 733
                 }else{
734
-                    filter_mb_mbaff_edgecv( h, img_cb,              2*uvlinesize, bS  , 2, bqp[0] );
735
-                    filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] );
736
-                    filter_mb_mbaff_edgecv( h, img_cr,              2*uvlinesize, bS  , 2, rqp[0] );
737
-                    filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] );
734
+                    filter_mb_mbaff_edgecv( h, img_cb,              2*uvlinesize, bS  , 2, bqp[0], a, b, 1 );
735
+                    filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
736
+                    filter_mb_mbaff_edgecv( h, img_cr,              2*uvlinesize, bS  , 2, rqp[0], a, b, 1 );
737
+                    filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
738 738
                 }
739 739
             }
740 740
         }
... ...
@@ -742,9 +754,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
742 742
 
743 743
 #if CONFIG_SMALL
744 744
     for( dir = 0; dir < 2; dir++ )
745
-        filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, chroma, CHROMA444, dir);
745
+        filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, CHROMA444, dir);
746 746
 #else
747
-    filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, chroma, CHROMA444, 0);
748
-    filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, chroma, CHROMA444, 1);
747
+    filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, CHROMA444, 0);
748
+    filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0,                        a, b, chroma, CHROMA444, 1);
749 749
 #endif
750 750
 }
... ...
@@ -48,15 +48,15 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C,
48 48
                 const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\
49 49
                 if(!USES_LIST(mb_type,list))\
50 50
                     return LIST_NOT_USED;\
51
-                mv = s->current_picture_ptr->motion_val[list][h->mb2b_xy[xy]+3 + y4*h->b_stride];\
51
+                mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4*h->b_stride];\
52 52
                 h->mv_cache[list][scan8[0]-2][0] = mv[0];\
53 53
                 h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\
54
-                return s->current_picture_ptr->ref_index[list][4*xy+1 + (y4&~1)] REF_OP;
54
+                return s->current_picture_ptr->f.ref_index[list][4*xy + 1 + (y4 & ~1)] REF_OP;
55 55
 
56 56
         if(topright_ref == PART_NOT_AVAILABLE
57 57
            && i >= scan8[0]+8 && (i&7)==4
58 58
            && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){
59
-            const uint32_t *mb_types = s->current_picture_ptr->mb_type;
59
+            const uint32_t *mb_types = s->current_picture_ptr->f.mb_type;
60 60
             const int16_t *mv;
61 61
             AV_ZERO32(h->mv_cache[list][scan8[0]-2]);
62 62
             *C = h->mv_cache[list][scan8[0]-2];
... ...
@@ -236,8 +236,8 @@ static av_always_inline void pred_pskip_motion(H264Context * const h){
236 236
     DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0};
237 237
     DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];
238 238
     MpegEncContext * const s = &h->s;
239
-    int8_t *ref = s->current_picture.ref_index[0];
240
-    int16_t (*mv)[2] = s->current_picture.motion_val[0];
239
+    int8_t *ref      = s->current_picture.f.ref_index[0];
240
+    int16_t (*mv)[2] = s->current_picture.f.motion_val[0];
241 241
     int top_ref, left_ref, diagonal_ref, match_count, mx, my;
242 242
     const int16_t *A, *B, *C;
243 243
     int b_stride = h->b_stride;
... ...
@@ -40,16 +40,16 @@ static void pic_as_field(Picture *pic, const int parity){
40 40
     int i;
41 41
     for (i = 0; i < 4; ++i) {
42 42
         if (parity == PICT_BOTTOM_FIELD)
43
-            pic->data[i] += pic->linesize[i];
44
-        pic->reference = parity;
45
-        pic->linesize[i] *= 2;
43
+            pic->f.data[i] += pic->f.linesize[i];
44
+        pic->f.reference    = parity;
45
+        pic->f.linesize[i] *= 2;
46 46
     }
47 47
     pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD];
48 48
 }
49 49
 
50 50
 static int split_field_copy(Picture *dest, Picture *src,
51 51
                             int parity, int id_add){
52
-    int match = !!(src->reference & parity);
52
+    int match = !!(src->f.reference & parity);
53 53
 
54 54
     if (match) {
55 55
         *dest = *src;
... ...
@@ -68,9 +68,9 @@ static int build_def_list(Picture *def, Picture **in, int len, int is_long, int
68 68
     int index=0;
69 69
 
70 70
     while(i[0]<len || i[1]<len){
71
-        while(i[0]<len && !(in[ i[0] ] && (in[ i[0] ]->reference & sel)))
71
+        while (i[0] < len && !(in[ i[0] ] && (in[ i[0] ]->f.reference & sel)))
72 72
             i[0]++;
73
-        while(i[1]<len && !(in[ i[1] ] && (in[ i[1] ]->reference & (sel^3))))
73
+        while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3))))
74 74
             i[1]++;
75 75
         if(i[0] < len){
76 76
             in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num;
... ...
@@ -134,7 +134,7 @@ int ff_h264_fill_default_ref_list(H264Context *h){
134 134
         }
135 135
 
136 136
         if(lens[0] == lens[1] && lens[1] > 1){
137
-            for(i=0; h->default_ref_list[0][i].data[0] == h->default_ref_list[1][i].data[0] && i<lens[0]; i++);
137
+            for (i = 0; h->default_ref_list[0][i].f.data[0] == h->default_ref_list[1][i].f.data[0] && i < lens[0]; i++);
138 138
             if(i == lens[0])
139 139
                 FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]);
140 140
         }
... ...
@@ -230,11 +230,11 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
230 230
 
231 231
                         for(i= h->short_ref_count-1; i>=0; i--){
232 232
                             ref = h->short_ref[i];
233
-                            assert(ref->reference);
233
+                            assert(ref->f.reference);
234 234
                             assert(!ref->long_ref);
235 235
                             if(
236 236
                                    ref->frame_num == frame_num &&
237
-                                   (ref->reference & pic_structure)
237
+                                   (ref->f.reference & pic_structure)
238 238
                               )
239 239
                                 break;
240 240
                         }
... ...
@@ -251,8 +251,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
251 251
                             return -1;
252 252
                         }
253 253
                         ref = h->long_ref[long_idx];
254
-                        assert(!(ref && !ref->reference));
255
-                        if(ref && (ref->reference & pic_structure)){
254
+                        assert(!(ref && !ref->f.reference));
255
+                        if (ref && (ref->f.reference & pic_structure)) {
256 256
                             ref->pic_id= pic_id;
257 257
                             assert(ref->long_ref);
258 258
                             i=0;
... ...
@@ -286,9 +286,9 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
286 286
     }
287 287
     for(list=0; list<h->list_count; list++){
288 288
         for(index= 0; index < h->ref_count[list]; index++){
289
-            if(!h->ref_list[list][index].data[0]){
289
+            if (!h->ref_list[list][index].f.data[0]) {
290 290
                 av_log(h->s.avctx, AV_LOG_ERROR, "Missing reference picture\n");
291
-                if(h->default_ref_list[list][0].data[0])
291
+                if (h->default_ref_list[list][0].f.data[0])
292 292
                     h->ref_list[list][index]= h->default_ref_list[list][0];
293 293
                 else
294 294
                     return -1;
... ...
@@ -307,13 +307,13 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h){
307 307
             Picture *field = &h->ref_list[list][16+2*i];
308 308
             field[0] = *frame;
309 309
             for(j=0; j<3; j++)
310
-                field[0].linesize[j] <<= 1;
311
-            field[0].reference = PICT_TOP_FIELD;
310
+                field[0].f.linesize[j] <<= 1;
311
+            field[0].f.reference = PICT_TOP_FIELD;
312 312
             field[0].poc= field[0].field_poc[0];
313 313
             field[1] = field[0];
314 314
             for(j=0; j<3; j++)
315
-                field[1].data[j] += frame->linesize[j];
316
-            field[1].reference = PICT_BOTTOM_FIELD;
315
+                field[1].f.data[j] += frame->f.linesize[j];
316
+            field[1].f.reference = PICT_BOTTOM_FIELD;
317 317
             field[1].poc= field[1].field_poc[1];
318 318
 
319 319
             h->luma_weight[16+2*i][list][0] = h->luma_weight[16+2*i+1][list][0] = h->luma_weight[i][list][0];
... ...
@@ -339,12 +339,12 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h){
339 339
  */
340 340
 static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){
341 341
     int i;
342
-    if (pic->reference &= refmask) {
342
+    if (pic->f.reference &= refmask) {
343 343
         return 0;
344 344
     } else {
345 345
         for(i = 0; h->delayed_pic[i]; i++)
346 346
             if(pic == h->delayed_pic[i]){
347
-                pic->reference=DELAYED_PIC_REF;
347
+                pic->f.reference = DELAYED_PIC_REF;
348 348
                 break;
349 349
             }
350 350
         return 1;
... ...
@@ -454,7 +454,8 @@ static void print_short_term(H264Context *h) {
454 454
         av_log(h->s.avctx, AV_LOG_DEBUG, "short term list:\n");
455 455
         for(i=0; i<h->short_ref_count; i++){
456 456
             Picture *pic= h->short_ref[i];
457
-            av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", i, pic->frame_num, pic->poc, pic->data[0]);
457
+            av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
458
+                   i, pic->frame_num, pic->poc, pic->f.data[0]);
458 459
         }
459 460
     }
460 461
 }
... ...
@@ -469,7 +470,8 @@ static void print_long_term(H264Context *h) {
469 469
         for(i = 0; i < 16; i++){
470 470
             Picture *pic= h->long_ref[i];
471 471
             if (pic) {
472
-                av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", i, pic->frame_num, pic->poc, pic->data[0]);
472
+                av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
473
+                       i, pic->frame_num, pic->poc, pic->f.data[0]);
473 474
             }
474 475
         }
475 476
     }
... ...
@@ -481,7 +483,7 @@ void ff_generate_sliding_window_mmcos(H264Context *h) {
481 481
 
482 482
     h->mmco_index= 0;
483 483
     if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
484
-            !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) {
484
+            !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) {
485 485
         h->mmco[0].opcode= MMCO_SHORT2UNUSED;
486 486
         h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
487 487
         h->mmco_index= 1;
... ...
@@ -562,7 +564,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
562 562
                 h->long_ref_count++;
563 563
             }
564 564
 
565
-            s->current_picture_ptr->reference |= s->picture_structure;
565
+            s->current_picture_ptr->f.reference |= s->picture_structure;
566 566
             current_ref_assigned=1;
567 567
             break;
568 568
         case MMCO_SET_MAX_LONG:
... ...
@@ -601,7 +603,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
601 601
          */
602 602
         if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) {
603 603
             /* Just mark the second field valid */
604
-            s->current_picture_ptr->reference = PICT_FRAME;
604
+            s->current_picture_ptr->f.reference = PICT_FRAME;
605 605
         } else if (s->current_picture_ptr->long_ref) {
606 606
             av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference "
607 607
                                              "assignment for second field "
... ...
@@ -618,7 +620,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
618 618
 
619 619
             h->short_ref[0]= s->current_picture_ptr;
620 620
             h->short_ref_count++;
621
-            s->current_picture_ptr->reference |= s->picture_structure;
621
+            s->current_picture_ptr->f.reference |= s->picture_structure;
622 622
         }
623 623
     }
624 624
 
... ...
@@ -304,7 +304,7 @@ static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma
304 304
     int quant;
305 305
 
306 306
     s->dsp.x8_setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer,
307
-                                          s->current_picture.linesize[chroma>0],
307
+                                          s->current_picture.f.linesize[chroma>0],
308 308
                                           &range, &sum, w->edges);
309 309
     if(chroma){
310 310
         w->orient=w->chroma_orient;
... ...
@@ -613,7 +613,7 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
613 613
             dc_level+= (w->predicted_dc*divide_quant + (1<<12) )>>13;
614 614
 
615 615
             dsp_x8_put_solidcolor( av_clip_uint8((dc_level*dc_quant+4)>>3),
616
-                                   s->dest[chroma], s->current_picture.linesize[!!chroma]);
616
+                                   s->dest[chroma], s->current_picture.f.linesize[!!chroma]);
617 617
 
618 618
             goto block_placed;
619 619
         }
... ...
@@ -637,15 +637,15 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
637 637
     }
638 638
 
639 639
     if(w->flat_dc){
640
-        dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.linesize[!!chroma]);
640
+        dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f.linesize[!!chroma]);
641 641
     }else{
642 642
         s->dsp.x8_spatial_compensation[w->orient]( s->edge_emu_buffer,
643 643
                                             s->dest[chroma],
644
-                                            s->current_picture.linesize[!!chroma] );
644
+                                            s->current_picture.f.linesize[!!chroma] );
645 645
     }
646 646
     if(!zeros_only)
647 647
         s->dsp.idct_add ( s->dest[chroma],
648
-                          s->current_picture.linesize[!!chroma],
648
+                          s->current_picture.f.linesize[!!chroma],
649 649
                           s->block[0] );
650 650
 
651 651
 block_placed:
... ...
@@ -656,7 +656,7 @@ block_placed:
656 656
 
657 657
     if(s->loop_filter){
658 658
         uint8_t* ptr = s->dest[chroma];
659
-        int linesize = s->current_picture.linesize[!!chroma];
659
+        int linesize = s->current_picture.f.linesize[!!chroma];
660 660
 
661 661
         if(!( (w->edges&2) || ( zeros_only && (w->orient|4)==4 ) )){
662 662
             s->dsp.x8_h_loop_filter(ptr, linesize, w->quant);
... ...
@@ -671,12 +671,12 @@ block_placed:
671 671
 static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
672 672
 //not s->linesize as this would be wrong for field pics
673 673
 //not that IntraX8 has interlacing support ;)
674
-    const int linesize  = s->current_picture.linesize[0];
675
-    const int uvlinesize= s->current_picture.linesize[1];
674
+    const int linesize   = s->current_picture.f.linesize[0];
675
+    const int uvlinesize = s->current_picture.f.linesize[1];
676 676
 
677
-    s->dest[0] = s->current_picture.data[0];
678
-    s->dest[1] = s->current_picture.data[1];
679
-    s->dest[2] = s->current_picture.data[2];
677
+    s->dest[0] = s->current_picture.f.data[0];
678
+    s->dest[1] = s->current_picture.f.data[1];
679
+    s->dest[2] = s->current_picture.f.data[2];
680 680
 
681 681
     s->dest[0] +=   s->mb_y        *   linesize << 3;
682 682
     s->dest[1] += ( s->mb_y&(~1) ) * uvlinesize << 2;//chroma blocks are on add rows
... ...
@@ -771,7 +771,7 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of
771 771
                 /*emulate MB info in the relevant tables*/
772 772
                 s->mbskip_table [mb_xy]=0;
773 773
                 s->mbintra_table[mb_xy]=1;
774
-                s->current_picture.qscale_table[mb_xy]=w->quant;
774
+                s->current_picture.f.qscale_table[mb_xy] = w->quant;
775 775
                 mb_xy++;
776 776
             }
777 777
             s->dest[0]+= 8;
... ...
@@ -353,20 +353,20 @@ static void preview_obmc(MpegEncContext *s){
353 353
     do{
354 354
         if (get_bits1(&s->gb)) {
355 355
             /* skip mb */
356
-            mot_val = s->current_picture.motion_val[0][ s->block_index[0] ];
356
+            mot_val = s->current_picture.f.motion_val[0][s->block_index[0]];
357 357
             mot_val[0       ]= mot_val[2       ]=
358 358
             mot_val[0+stride]= mot_val[2+stride]= 0;
359 359
             mot_val[1       ]= mot_val[3       ]=
360 360
             mot_val[1+stride]= mot_val[3+stride]= 0;
361 361
 
362
-            s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
362
+            s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
363 363
             goto end;
364 364
         }
365 365
         cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
366 366
     }while(cbpc == 20);
367 367
 
368 368
     if(cbpc & 4){
369
-        s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
369
+        s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
370 370
     }else{
371 371
         get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
372 372
         if (cbpc & 8) {
... ...
@@ -378,7 +378,7 @@ static void preview_obmc(MpegEncContext *s){
378 378
         }
379 379
 
380 380
         if ((cbpc & 16) == 0) {
381
-                s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
381
+                s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
382 382
                 /* 16x16 motion prediction */
383 383
                 mot_val= h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
384 384
                 if (s->umvplus)
... ...
@@ -396,7 +396,7 @@ static void preview_obmc(MpegEncContext *s){
396 396
                 mot_val[1       ]= mot_val[3       ]=
397 397
                 mot_val[1+stride]= mot_val[3+stride]= my;
398 398
         } else {
399
-            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
399
+            s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
400 400
             for(i=0;i<4;i++) {
401 401
                 mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
402 402
                 if (s->umvplus)
... ...
@@ -618,7 +618,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
618 618
                     s->block_last_index[i] = -1;
619 619
                 s->mv_dir = MV_DIR_FORWARD;
620 620
                 s->mv_type = MV_TYPE_16X16;
621
-                s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
621
+                s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
622 622
                 s->mv[0][0][0] = 0;
623 623
                 s->mv[0][0][1] = 0;
624 624
                 s->mb_skipped = !(s->obmc | s->loop_filter);
... ...
@@ -651,7 +651,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
651 651
 
652 652
         s->mv_dir = MV_DIR_FORWARD;
653 653
         if ((cbpc & 16) == 0) {
654
-            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
654
+            s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
655 655
             /* 16x16 motion prediction */
656 656
             s->mv_type = MV_TYPE_16X16;
657 657
             h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
... ...
@@ -676,7 +676,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
676 676
             if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
677 677
                skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
678 678
         } else {
679
-            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
679
+            s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
680 680
             s->mv_type = MV_TYPE_8X8;
681 681
             for(i=0;i<4;i++) {
682 682
                 mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
... ...
@@ -704,8 +704,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
704 704
     } else if(s->pict_type==AV_PICTURE_TYPE_B) {
705 705
         int mb_type;
706 706
         const int stride= s->b8_stride;
707
-        int16_t *mot_val0 = s->current_picture.motion_val[0][ 2*(s->mb_x + s->mb_y*stride) ];
708
-        int16_t *mot_val1 = s->current_picture.motion_val[1][ 2*(s->mb_x + s->mb_y*stride) ];
707
+        int16_t *mot_val0 = s->current_picture.f.motion_val[0][2 * (s->mb_x + s->mb_y * stride)];
708
+        int16_t *mot_val1 = s->current_picture.f.motion_val[1][2 * (s->mb_x + s->mb_y * stride)];
709 709
 //        const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
710 710
 
711 711
         //FIXME ugly
... ...
@@ -788,7 +788,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
788 788
             }
789 789
         }
790 790
 
791
-        s->current_picture.mb_type[xy]= mb_type;
791
+        s->current_picture.f.mb_type[xy] = mb_type;
792 792
     } else { /* I-Frame */
793 793
         do{
794 794
             cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
... ...
@@ -803,11 +803,11 @@ int ff_h263_decode_mb(MpegEncContext *s,
803 803
         dquant = cbpc & 4;
804 804
         s->mb_intra = 1;
805 805
 intra:
806
-        s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
806
+        s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
807 807
         if (s->h263_aic) {
808 808
             s->ac_pred = get_bits1(&s->gb);
809 809
             if(s->ac_pred){
810
-                s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED;
810
+                s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
811 811
 
812 812
                 s->h263_aic_dir = get_bits1(&s->gb);
813 813
             }
... ...
@@ -889,7 +889,7 @@ int h263_decode_picture_header(MpegEncContext *s)
889 889
     i = get_bits(&s->gb, 8); /* picture timestamp */
890 890
     if( (s->picture_number&~0xFF)+i < s->picture_number)
891 891
         i+= 256;
892
-    s->current_picture_ptr->pts=
892
+    s->current_picture_ptr->f.pts =
893 893
     s->picture_number= (s->picture_number&~0xFF) + i;
894 894
 
895 895
     /* PTYPE starts here */
... ...
@@ -275,7 +275,7 @@ void h263_encode_gob_header(MpegEncContext * s, int mb_line)
275 275
  */
276 276
 void ff_clean_h263_qscales(MpegEncContext *s){
277 277
     int i;
278
-    int8_t * const qscale_table= s->current_picture.qscale_table;
278
+    int8_t * const qscale_table = s->current_picture.f.qscale_table;
279 279
 
280 280
     ff_init_qscale_tab(s);
281 281
 
... ...
@@ -529,8 +529,8 @@ void h263_encode_mb(MpegEncContext * s,
529 529
                 /* motion vectors: 8x8 mode*/
530 530
                 h263_pred_motion(s, i, 0, &pred_x, &pred_y);
531 531
 
532
-                motion_x= s->current_picture.motion_val[0][ s->block_index[i] ][0];
533
-                motion_y= s->current_picture.motion_val[0][ s->block_index[i] ][1];
532
+                motion_x = s->current_picture.f.motion_val[0][s->block_index[i]][0];
533
+                motion_y = s->current_picture.f.motion_val[0][s->block_index[i]][1];
534 534
                 if (!s->umvplus) {
535 535
                     ff_h263_encode_motion_vector(s, motion_x - pred_x,
536 536
                                                     motion_y - pred_y, 1);
... ...
@@ -533,16 +533,16 @@ static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4)
533 533
     if(mv4){
534 534
         int mot_xy= s->block_index[0];
535 535
 
536
-        s->current_picture.motion_val[0][mot_xy  ][0]= mx;
537
-        s->current_picture.motion_val[0][mot_xy  ][1]= my;
538
-        s->current_picture.motion_val[0][mot_xy+1][0]= mx;
539
-        s->current_picture.motion_val[0][mot_xy+1][1]= my;
536
+        s->current_picture.f.motion_val[0][mot_xy    ][0] = mx;
537
+        s->current_picture.f.motion_val[0][mot_xy    ][1] = my;
538
+        s->current_picture.f.motion_val[0][mot_xy + 1][0] = mx;
539
+        s->current_picture.f.motion_val[0][mot_xy + 1][1] = my;
540 540
 
541 541
         mot_xy += s->b8_stride;
542
-        s->current_picture.motion_val[0][mot_xy  ][0]= mx;
543
-        s->current_picture.motion_val[0][mot_xy  ][1]= my;
544
-        s->current_picture.motion_val[0][mot_xy+1][0]= mx;
545
-        s->current_picture.motion_val[0][mot_xy+1][1]= my;
542
+        s->current_picture.f.motion_val[0][mot_xy    ][0] = mx;
543
+        s->current_picture.f.motion_val[0][mot_xy    ][1] = my;
544
+        s->current_picture.f.motion_val[0][mot_xy + 1][0] = mx;
545
+        s->current_picture.f.motion_val[0][mot_xy + 1][1] = my;
546 546
     }
547 547
 }
548 548
 
... ...
@@ -615,8 +615,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
615 615
         const int mot_stride = s->b8_stride;
616 616
         const int mot_xy = s->block_index[block];
617 617
 
618
-        P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
619
-        P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];
618
+        P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0];
619
+        P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1];
620 620
 
621 621
         if(P_LEFT[0]       > (c->xmax<<shift)) P_LEFT[0]       = (c->xmax<<shift);
622 622
 
... ...
@@ -625,10 +625,10 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
625 625
             c->pred_x= pred_x4= P_LEFT[0];
626 626
             c->pred_y= pred_y4= P_LEFT[1];
627 627
         } else {
628
-            P_TOP[0]      = s->current_picture.motion_val[0][mot_xy - mot_stride             ][0];
629
-            P_TOP[1]      = s->current_picture.motion_val[0][mot_xy - mot_stride             ][1];
630
-            P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][0];
631
-            P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][1];
628
+            P_TOP[0]      = s->current_picture.f.motion_val[0][mot_xy - mot_stride             ][0];
629
+            P_TOP[1]      = s->current_picture.f.motion_val[0][mot_xy - mot_stride             ][1];
630
+            P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + off[block]][0];
631
+            P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + off[block]][1];
632 632
             if(P_TOP[1]      > (c->ymax<<shift)) P_TOP[1]     = (c->ymax<<shift);
633 633
             if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
634 634
             if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);
... ...
@@ -680,8 +680,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
680 680
             my4_sum+= my4;
681 681
         }
682 682
 
683
-        s->current_picture.motion_val[0][ s->block_index[block] ][0]= mx4;
684
-        s->current_picture.motion_val[0][ s->block_index[block] ][1]= my4;
683
+        s->current_picture.f.motion_val[0][s->block_index[block]][0] = mx4;
684
+        s->current_picture.f.motion_val[0][s->block_index[block]][1] = my4;
685 685
 
686 686
         if(mx4 != mx || my4 != my) same=0;
687 687
     }
... ...
@@ -690,7 +690,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
690 690
         return INT_MAX;
691 691
 
692 692
     if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
693
-        dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
693
+        dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
694 694
     }
695 695
 
696 696
     if(c->avctx->mb_cmp&FF_CMP_CHROMA){
... ...
@@ -705,15 +705,15 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
705 705
         offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
706 706
 
707 707
         if(s->no_rounding){
708
-            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad    , s->last_picture.data[1] + offset, s->uvlinesize, 8);
709
-            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad+8  , s->last_picture.data[2] + offset, s->uvlinesize, 8);
708
+            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad    , s->last_picture.f.data[1] + offset, s->uvlinesize, 8);
709
+            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8);
710 710
         }else{
711
-            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad    , s->last_picture.data[1] + offset, s->uvlinesize, 8);
712
-            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad+8  , s->last_picture.data[2] + offset, s->uvlinesize, 8);
711
+            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad    , s->last_picture.f.data[1] + offset, s->uvlinesize, 8);
712
+            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8);
713 713
         }
714 714
 
715
-        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad  , s->uvlinesize, 8);
716
-        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
715
+        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad  , s->uvlinesize, 8);
716
+        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
717 717
     }
718 718
 
719 719
     c->pred_x= mx;
... ...
@@ -879,7 +879,7 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
879 879
     Picture *p= s->current_picture_ptr;
880 880
     int mb_xy= mb_x + mb_y*s->mb_stride;
881 881
     int xy= 2*mb_x + 2*mb_y*s->b8_stride;
882
-    int mb_type= s->current_picture.mb_type[mb_xy];
882
+    int mb_type= s->current_picture.f.mb_type[mb_xy];
883 883
     int flags= c->flags;
884 884
     int shift= (flags&FLAG_QPEL) + 1;
885 885
     int mask= (1<<shift)-1;
... ...
@@ -896,8 +896,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
896 896
 
897 897
     for(i=0; i<4; i++){
898 898
         int xy= s->block_index[i];
899
-        clip_input_mv(s, p->motion_val[0][xy], !!IS_INTERLACED(mb_type));
900
-        clip_input_mv(s, p->motion_val[1][xy], !!IS_INTERLACED(mb_type));
899
+        clip_input_mv(s, p->f.motion_val[0][xy], !!IS_INTERLACED(mb_type));
900
+        clip_input_mv(s, p->f.motion_val[1][xy], !!IS_INTERLACED(mb_type));
901 901
     }
902 902
 
903 903
     if(IS_INTERLACED(mb_type)){
... ...
@@ -912,8 +912,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
912 912
         }
913 913
 
914 914
         if(USES_LIST(mb_type, 0)){
915
-            int field_select0= p->ref_index[0][4*mb_xy  ];
916
-            int field_select1= p->ref_index[0][4*mb_xy+2];
915
+            int field_select0= p->f.ref_index[0][4*mb_xy  ];
916
+            int field_select1= p->f.ref_index[0][4*mb_xy+2];
917 917
             assert(field_select0==0 ||field_select0==1);
918 918
             assert(field_select1==0 ||field_select1==1);
919 919
             init_interlaced_ref(s, 0);
... ...
@@ -921,46 +921,46 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
921 921
             if(p_type){
922 922
                 s->p_field_select_table[0][mb_xy]= field_select0;
923 923
                 s->p_field_select_table[1][mb_xy]= field_select1;
924
-                *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];
925
-                *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];
924
+                *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy ];
925
+                *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy2];
926 926
                 s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I;
927 927
             }else{
928 928
                 s->b_field_select_table[0][0][mb_xy]= field_select0;
929 929
                 s->b_field_select_table[0][1][mb_xy]= field_select1;
930
-                *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];
931
-                *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];
930
+                *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy ];
931
+                *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy2];
932 932
                 s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I;
933 933
             }
934 934
 
935
-            x= p->motion_val[0][xy ][0];
936
-            y= p->motion_val[0][xy ][1];
935
+            x = p->f.motion_val[0][xy ][0];
936
+            y = p->f.motion_val[0][xy ][1];
937 937
             d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags);
938
-            x= p->motion_val[0][xy2][0];
939
-            y= p->motion_val[0][xy2][1];
938
+            x = p->f.motion_val[0][xy2][0];
939
+            y = p->f.motion_val[0][xy2][1];
940 940
             d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);
941 941
         }
942 942
         if(USES_LIST(mb_type, 1)){
943
-            int field_select0= p->ref_index[1][4*mb_xy  ];
944
-            int field_select1= p->ref_index[1][4*mb_xy+2];
943
+            int field_select0 = p->f.ref_index[1][4 * mb_xy    ];
944
+            int field_select1 = p->f.ref_index[1][4 * mb_xy + 2];
945 945
             assert(field_select0==0 ||field_select0==1);
946 946
             assert(field_select1==0 ||field_select1==1);
947 947
             init_interlaced_ref(s, 2);
948 948
 
949 949
             s->b_field_select_table[1][0][mb_xy]= field_select0;
950 950
             s->b_field_select_table[1][1][mb_xy]= field_select1;
951
-            *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[1][xy ];
952
-            *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[1][xy2];
951
+            *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[1][xy ];
952
+            *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[1][xy2];
953 953
             if(USES_LIST(mb_type, 0)){
954 954
                 s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I;
955 955
             }else{
956 956
                 s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I;
957 957
             }
958 958
 
959
-            x= p->motion_val[1][xy ][0];
960
-            y= p->motion_val[1][xy ][1];
959
+            x = p->f.motion_val[1][xy ][0];
960
+            y = p->f.motion_val[1][xy ][1];
961 961
             d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags);
962
-            x= p->motion_val[1][xy2][0];
963
-            y= p->motion_val[1][xy2][1];
962
+            x = p->f.motion_val[1][xy2][0];
963
+            y = p->f.motion_val[1][xy2][1];
964 964
             d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags);
965 965
             //FIXME bidir scores
966 966
         }
... ...
@@ -976,33 +976,33 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
976 976
         init_mv4_ref(c);
977 977
         for(i=0; i<4; i++){
978 978
             xy= s->block_index[i];
979
-            x= p->motion_val[0][xy][0];
980
-            y= p->motion_val[0][xy][1];
979
+            x= p->f.motion_val[0][xy][0];
980
+            y= p->f.motion_val[0][xy][1];
981 981
             d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);
982 982
         }
983 983
         s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V;
984 984
     }else{
985 985
         if(USES_LIST(mb_type, 0)){
986 986
             if(p_type){
987
-                *(uint32_t*)s->p_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];
987
+                *(uint32_t*)s->p_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy];
988 988
                 s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER;
989 989
             }else if(USES_LIST(mb_type, 1)){
990
-                *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];
991
-                *(uint32_t*)s->b_bidir_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];
990
+                *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy];
991
+                *(uint32_t*)s->b_bidir_back_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[1][xy];
992 992
                 s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR;
993 993
             }else{
994
-                *(uint32_t*)s->b_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];
994
+                *(uint32_t*)s->b_forw_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy];
995 995
                 s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD;
996 996
             }
997
-            x= p->motion_val[0][xy][0];
998
-            y= p->motion_val[0][xy][1];
997
+            x = p->f.motion_val[0][xy][0];
998
+            y = p->f.motion_val[0][xy][1];
999 999
             d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags);
1000 1000
         }else if(USES_LIST(mb_type, 1)){
1001
-            *(uint32_t*)s->b_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];
1001
+            *(uint32_t*)s->b_back_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[1][xy];
1002 1002
             s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD;
1003 1003
 
1004
-            x= p->motion_val[1][xy][0];
1005
-            y= p->motion_val[1][xy][1];
1004
+            x = p->f.motion_val[1][xy][0];
1005
+            y = p->f.motion_val[1][xy][1];
1006 1006
             d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags);
1007 1007
         }else
1008 1008
             s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;
... ...
@@ -1023,7 +1023,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
1023 1023
     int mb_type=0;
1024 1024
     Picture * const pic= &s->current_picture;
1025 1025
 
1026
-    init_ref(c, s->new_picture.data, s->last_picture.data, NULL, 16*mb_x, 16*mb_y, 0);
1026
+    init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
1027 1027
 
1028 1028
     assert(s->quarter_sample==0 || s->quarter_sample==1);
1029 1029
     assert(s->linesize == c->stride);
... ...
@@ -1075,16 +1075,16 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
1075 1075
             const int mot_stride = s->b8_stride;
1076 1076
             const int mot_xy = s->block_index[0];
1077 1077
 
1078
-            P_LEFT[0]       = s->current_picture.motion_val[0][mot_xy - 1][0];
1079
-            P_LEFT[1]       = s->current_picture.motion_val[0][mot_xy - 1][1];
1078
+            P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0];
1079
+            P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1];
1080 1080
 
1081 1081
             if(P_LEFT[0]       > (c->xmax<<shift)) P_LEFT[0]       = (c->xmax<<shift);
1082 1082
 
1083 1083
             if(!s->first_slice_line) {
1084
-                P_TOP[0]      = s->current_picture.motion_val[0][mot_xy - mot_stride    ][0];
1085
-                P_TOP[1]      = s->current_picture.motion_val[0][mot_xy - mot_stride    ][1];
1086
-                P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0];
1087
-                P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1];
1084
+                P_TOP[0]      = s->current_picture.f.motion_val[0][mot_xy - mot_stride    ][0];
1085
+                P_TOP[1]      = s->current_picture.f.motion_val[0][mot_xy - mot_stride    ][1];
1086
+                P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][0];
1087
+                P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][1];
1088 1088
                 if(P_TOP[1]      > (c->ymax<<shift)) P_TOP[1]     = (c->ymax<<shift);
1089 1089
                 if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
1090 1090
                 if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
... ...
@@ -1226,7 +1226,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
1226 1226
                 }else{
1227 1227
                     mean= (s->last_dc[i] + 4)>>3;
1228 1228
                 }
1229
-                dest_c = s->new_picture.data[i] + (mb_y * 8  * (s->uvlinesize)) + mb_x * 8;
1229
+                dest_c = s->new_picture.f.data[i] + (mb_y * 8  * (s->uvlinesize)) + mb_x * 8;
1230 1230
 
1231 1231
                 mean*= 0x01010101;
1232 1232
                 for(i=0; i<8; i++){
... ...
@@ -1242,9 +1242,9 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
1242 1242
 
1243 1243
         if(intra_score < dmin){
1244 1244
             mb_type= CANDIDATE_MB_TYPE_INTRA;
1245
-            s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_INTRA; //FIXME cleanup
1245
+            s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = CANDIDATE_MB_TYPE_INTRA; //FIXME cleanup
1246 1246
         }else
1247
-            s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= 0;
1247
+            s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = 0;
1248 1248
 
1249 1249
         {
1250 1250
             int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
... ...
@@ -1264,7 +1264,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
1264 1264
     int P[10][2];
1265 1265
     const int shift= 1+s->quarter_sample;
1266 1266
     const int xy= mb_x + mb_y*s->mb_stride;
1267
-    init_ref(c, s->new_picture.data, s->last_picture.data, NULL, 16*mb_x, 16*mb_y, 0);
1267
+    init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
1268 1268
 
1269 1269
     assert(s->quarter_sample==0 || s->quarter_sample==1);
1270 1270
 
... ...
@@ -1615,7 +1615,7 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y)
1615 1615
     ymin= xmin=(-32)>>shift;
1616 1616
     ymax= xmax=   31>>shift;
1617 1617
 
1618
-    if(IS_8X8(s->next_picture.mb_type[mot_xy])){
1618
+    if (IS_8X8(s->next_picture.f.mb_type[mot_xy])) {
1619 1619
         s->mv_type= MV_TYPE_8X8;
1620 1620
     }else{
1621 1621
         s->mv_type= MV_TYPE_16X16;
... ...
@@ -1625,8 +1625,8 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y)
1625 1625
         int index= s->block_index[i];
1626 1626
         int min, max;
1627 1627
 
1628
-        c->co_located_mv[i][0]= s->next_picture.motion_val[0][index][0];
1629
-        c->co_located_mv[i][1]= s->next_picture.motion_val[0][index][1];
1628
+        c->co_located_mv[i][0] = s->next_picture.f.motion_val[0][index][0];
1629
+        c->co_located_mv[i][1] = s->next_picture.f.motion_val[0][index][1];
1630 1630
         c->direct_basis_mv[i][0]= c->co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3));
1631 1631
         c->direct_basis_mv[i][1]= c->co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3));
1632 1632
 //        c->direct_basis_mv[1][i][0]= c->co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3);
... ...
@@ -1708,13 +1708,14 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
1708 1708
     int fmin, bmin, dmin, fbmin, bimin, fimin;
1709 1709
     int type=0;
1710 1710
     const int xy = mb_y*s->mb_stride + mb_x;
1711
-    init_ref(c, s->new_picture.data, s->last_picture.data, s->next_picture.data, 16*mb_x, 16*mb_y, 2);
1711
+    init_ref(c, s->new_picture.f.data, s->last_picture.f.data,
1712
+             s->next_picture.f.data, 16 * mb_x, 16 * mb_y, 2);
1712 1713
 
1713 1714
     get_limits(s, 16*mb_x, 16*mb_y);
1714 1715
 
1715 1716
     c->skip=0;
1716 1717
 
1717
-    if(s->codec_id == CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]){
1718
+    if (s->codec_id == CODEC_ID_MPEG4 && s->next_picture.f.mbskip_table[xy]) {
1718 1719
         int score= direct_search(s, mb_x, mb_y); //FIXME just check 0,0
1719 1720
 
1720 1721
         score= ((unsigned)(score*score + 128*256))>>16;
... ...
@@ -1947,14 +1948,14 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
1947 1947
                     int block;
1948 1948
                     for(block=0; block<4; block++){
1949 1949
                         int off= (block& 1) + (block>>1)*wrap;
1950
-                        int mx= s->current_picture.motion_val[0][ xy + off ][0];
1951
-                        int my= s->current_picture.motion_val[0][ xy + off ][1];
1950
+                        int mx = s->current_picture.f.motion_val[0][ xy + off ][0];
1951
+                        int my = s->current_picture.f.motion_val[0][ xy + off ][1];
1952 1952
 
1953 1953
                         if(   mx >=range || mx <-range
1954 1954
                            || my >=range || my <-range){
1955 1955
                             s->mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V;
1956 1956
                             s->mb_type[i] |= CANDIDATE_MB_TYPE_INTRA;
1957
-                            s->current_picture.mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
1957
+                            s->current_picture.f.mb_type[i] = CANDIDATE_MB_TYPE_INTRA;
1958 1958
                         }
1959 1959
                     }
1960 1960
                 }
... ...
@@ -217,20 +217,20 @@ static int mpeg_decode_mb(MpegEncContext *s,
217 217
     if (s->mb_skip_run-- != 0) {
218 218
         if (s->pict_type == AV_PICTURE_TYPE_P) {
219 219
             s->mb_skipped = 1;
220
-            s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
220
+            s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
221 221
         } else {
222 222
             int mb_type;
223 223
 
224 224
             if(s->mb_x)
225
-                mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1];
225
+                mb_type = s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1];
226 226
             else
227
-                mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in MPEG at all
227
+                mb_type = s->current_picture.f.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1]; // FIXME not sure if this is allowed in MPEG at all
228 228
             if(IS_INTRA(mb_type))
229 229
                 return -1;
230 230
 
231
-            s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
231
+            s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
232 232
                 mb_type | MB_TYPE_SKIP;
233
-//            assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
233
+//            assert(s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
234 234
 
235 235
             if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
236 236
                 s->mb_skipped = 1;
... ...
@@ -581,7 +581,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
581 581
         }
582 582
     }
583 583
 
584
-    s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type;
584
+    s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = mb_type;
585 585
 
586 586
     return 0;
587 587
 }
... ...
@@ -1423,8 +1423,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
1423 1423
         s->mpeg_f_code[1][0] = f_code;
1424 1424
         s->mpeg_f_code[1][1] = f_code;
1425 1425
     }
1426
-    s->current_picture.pict_type= s->pict_type;
1427
-    s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I;
1426
+    s->current_picture.f.pict_type = s->pict_type;
1427
+    s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
1428 1428
 
1429 1429
     if(avctx->debug & FF_DEBUG_PICT_INFO)
1430 1430
         av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
... ...
@@ -1577,8 +1577,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
1577 1577
                 s->pict_type= AV_PICTURE_TYPE_P;
1578 1578
         }else
1579 1579
             s->pict_type= AV_PICTURE_TYPE_B;
1580
-        s->current_picture.pict_type= s->pict_type;
1581
-        s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I;
1580
+        s->current_picture.f.pict_type = s->pict_type;
1581
+        s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
1582 1582
     }
1583 1583
     s->intra_dc_precision = get_bits(&s->gb, 2);
1584 1584
     s->picture_structure = get_bits(&s->gb, 2);
... ...
@@ -1655,19 +1655,19 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
1655 1655
         ff_er_frame_start(s);
1656 1656
 
1657 1657
         /* first check if we must repeat the frame */
1658
-        s->current_picture_ptr->repeat_pict = 0;
1658
+        s->current_picture_ptr->f.repeat_pict = 0;
1659 1659
         if (s->repeat_first_field) {
1660 1660
             if (s->progressive_sequence) {
1661 1661
                 if (s->top_field_first)
1662
-                    s->current_picture_ptr->repeat_pict = 4;
1662
+                    s->current_picture_ptr->f.repeat_pict = 4;
1663 1663
                 else
1664
-                    s->current_picture_ptr->repeat_pict = 2;
1664
+                    s->current_picture_ptr->f.repeat_pict = 2;
1665 1665
             } else if (s->progressive_frame) {
1666
-                s->current_picture_ptr->repeat_pict = 1;
1666
+                s->current_picture_ptr->f.repeat_pict = 1;
1667 1667
             }
1668 1668
         }
1669 1669
 
1670
-        *s->current_picture_ptr->pan_scan= s1->pan_scan;
1670
+        *s->current_picture_ptr->f.pan_scan = s1->pan_scan;
1671 1671
 
1672 1672
         if (HAVE_PTHREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
1673 1673
             ff_thread_finish_setup(avctx);
... ...
@@ -1680,9 +1680,9 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
1680 1680
             }
1681 1681
 
1682 1682
             for(i=0; i<4; i++){
1683
-                s->current_picture.data[i] = s->current_picture_ptr->data[i];
1683
+                s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i];
1684 1684
                 if(s->picture_structure == PICT_BOTTOM_FIELD){
1685
-                    s->current_picture.data[i] += s->current_picture_ptr->linesize[i];
1685
+                    s->current_picture.f.data[i] += s->current_picture_ptr->f.linesize[i];
1686 1686
                 }
1687 1687
             }
1688 1688
     }
... ...
@@ -1804,7 +1804,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
1804 1804
         if(mpeg_decode_mb(s, s->block) < 0)
1805 1805
             return -1;
1806 1806
 
1807
-        if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs
1807
+        if (s->current_picture.f.motion_val[0] && !s->encoding) { //note motion_val is normally NULL unless we want to extract the MVs
1808 1808
             const int wrap = s->b8_stride;
1809 1809
             int xy = s->mb_x*2 + s->mb_y*2*wrap;
1810 1810
             int b8_xy= 4*(s->mb_x + s->mb_y*s->mb_stride);
... ...
@@ -1822,12 +1822,12 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
1822 1822
                         motion_y = s->mv[dir][i][1];
1823 1823
                     }
1824 1824
 
1825
-                    s->current_picture.motion_val[dir][xy    ][0] = motion_x;
1826
-                    s->current_picture.motion_val[dir][xy    ][1] = motion_y;
1827
-                    s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
1828
-                    s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
1829
-                    s->current_picture.ref_index [dir][b8_xy    ]=
1830
-                    s->current_picture.ref_index [dir][b8_xy + 1]= s->field_select[dir][i];
1825
+                    s->current_picture.f.motion_val[dir][xy    ][0] = motion_x;
1826
+                    s->current_picture.f.motion_val[dir][xy    ][1] = motion_y;
1827
+                    s->current_picture.f.motion_val[dir][xy + 1][0] = motion_x;
1828
+                    s->current_picture.f.motion_val[dir][xy + 1][1] = motion_y;
1829
+                    s->current_picture.f.ref_index [dir][b8_xy    ] =
1830
+                    s->current_picture.f.ref_index [dir][b8_xy + 1] = s->field_select[dir][i];
1831 1831
                     assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1);
1832 1832
                 }
1833 1833
                 xy += wrap;
... ...
@@ -1991,7 +1991,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
1991 1991
     if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) {
1992 1992
         /* end of image */
1993 1993
 
1994
-        s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2;
1994
+        s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_MPEG2;
1995 1995
 
1996 1996
         ff_er_frame_end(s);
1997 1997
 
... ...
@@ -200,7 +200,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
200 200
 
201 201
         if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA)
202 202
 
203
-        if (s->current_picture.key_frame) {
203
+        if (s->current_picture.f.key_frame) {
204 204
             AVRational framerate= ff_frame_rate_tab[s->frame_rate_index];
205 205
 
206 206
             /* mpeg1 header repeated every gop */
... ...
@@ -287,9 +287,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
287 287
             /* time code : we must convert from the real frame rate to a
288 288
                fake mpeg frame rate in case of low frame rate */
289 289
             fps = (framerate.num + framerate.den/2)/ framerate.den;
290
-            time_code = s->current_picture_ptr->coded_picture_number + s->avctx->timecode_frame_start;
290
+            time_code = s->current_picture_ptr->f.coded_picture_number + s->avctx->timecode_frame_start;
291 291
 
292
-            s->gop_picture_number = s->current_picture_ptr->coded_picture_number;
292
+            s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
293 293
             if (s->avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) {
294 294
                 /* only works for NTSC 29.97 */
295 295
                 int d = time_code / 17982;
... ...
@@ -396,7 +396,7 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
396 396
         if (s->progressive_sequence) {
397 397
             put_bits(&s->pb, 1, 0); /* no repeat */
398 398
         } else {
399
-            put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
399
+            put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first);
400 400
         }
401 401
         /* XXX: optimize the generation of this flag with entropy
402 402
            measures */
... ...
@@ -89,7 +89,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my,
89 89
     uint16_t time_pb= s->pb_time;
90 90
     int p_mx, p_my;
91 91
 
92
-    p_mx= s->next_picture.motion_val[0][xy][0];
92
+    p_mx = s->next_picture.f.motion_val[0][xy][0];
93 93
     if((unsigned)(p_mx + tab_bias) < tab_size){
94 94
         s->mv[0][i][0] = s->direct_scale_mv[0][p_mx + tab_bias] + mx;
95 95
         s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx
... ...
@@ -99,7 +99,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my,
99 99
         s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx
100 100
                             : p_mx*(time_pb - time_pp)/time_pp;
101 101
     }
102
-    p_my= s->next_picture.motion_val[0][xy][1];
102
+    p_my = s->next_picture.f.motion_val[0][xy][1];
103 103
     if((unsigned)(p_my + tab_bias) < tab_size){
104 104
         s->mv[0][i][1] = s->direct_scale_mv[0][p_my + tab_bias] + my;
105 105
         s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my
... ...
@@ -120,7 +120,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my,
120 120
  */
121 121
 int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
122 122
     const int mb_index= s->mb_x + s->mb_y*s->mb_stride;
123
-    const int colocated_mb_type= s->next_picture.mb_type[mb_index];
123
+    const int colocated_mb_type = s->next_picture.f.mb_type[mb_index];
124 124
     uint16_t time_pp;
125 125
     uint16_t time_pb;
126 126
     int i;
... ...
@@ -137,7 +137,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
137 137
     } else if(IS_INTERLACED(colocated_mb_type)){
138 138
         s->mv_type = MV_TYPE_FIELD;
139 139
         for(i=0; i<2; i++){
140
-            int field_select= s->next_picture.ref_index[0][4*mb_index + 2*i];
140
+            int field_select = s->next_picture.f.ref_index[0][4 * mb_index + 2 * i];
141 141
             s->field_select[0][i]= field_select;
142 142
             s->field_select[1][i]= i;
143 143
             if(s->top_field_first){
... ...
@@ -55,7 +55,7 @@ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
55 55
 {
56 56
     int i;
57 57
     int16_t *ac_val, *ac_val1;
58
-    int8_t * const qscale_table= s->current_picture.qscale_table;
58
+    int8_t * const qscale_table = s->current_picture.f.qscale_table;
59 59
 
60 60
     /* find prediction */
61 61
     ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
... ...
@@ -376,7 +376,7 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s)
376 376
     if(s->pict_type == AV_PICTURE_TYPE_B){
377 377
         int mb_x = 0, mb_y = 0;
378 378
 
379
-        while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) {
379
+        while (s->next_picture.f.mbskip_table[s->mb_index2xy[mb_num]]) {
380 380
             if (!mb_x) ff_thread_await_progress((AVFrame*)s->next_picture_ptr, mb_y++, 0);
381 381
             mb_num++;
382 382
             if (++mb_x == s->mb_width) mb_x = 0;
... ...
@@ -570,13 +570,13 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
570 570
                 }while(cbpc == 8);
571 571
 
572 572
                 s->cbp_table[xy]= cbpc & 3;
573
-                s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
573
+                s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
574 574
                 s->mb_intra = 1;
575 575
 
576 576
                 if(cbpc & 4) {
577 577
                     ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
578 578
                 }
579
-                s->current_picture.qscale_table[xy]= s->qscale;
579
+                s->current_picture.f.qscale_table[xy]= s->qscale;
580 580
 
581 581
                 s->mbintra_table[xy]= 1;
582 582
                 for(i=0; i<6; i++){
... ...
@@ -592,7 +592,7 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
592 592
                 s->pred_dir_table[xy]= dir;
593 593
             }else{ /* P/S_TYPE */
594 594
                 int mx, my, pred_x, pred_y, bits;
595
-                int16_t * const mot_val= s->current_picture.motion_val[0][s->block_index[0]];
595
+                int16_t * const mot_val = s->current_picture.f.motion_val[0][s->block_index[0]];
596 596
                 const int stride= s->b8_stride*2;
597 597
 
598 598
 try_again:
... ...
@@ -604,11 +604,11 @@ try_again:
604 604
                 if(bits&0x10000){
605 605
                     /* skip mb */
606 606
                     if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
607
-                        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
607
+                        s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
608 608
                         mx= get_amv(s, 0);
609 609
                         my= get_amv(s, 1);
610 610
                     }else{
611
-                        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
611
+                        s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
612 612
                         mx=my=0;
613 613
                     }
614 614
                     mot_val[0       ]= mot_val[2       ]=
... ...
@@ -634,7 +634,7 @@ try_again:
634 634
                 s->mb_intra = ((cbpc & 4) != 0);
635 635
 
636 636
                 if(s->mb_intra){
637
-                    s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
637
+                    s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
638 638
                     s->mbintra_table[xy]= 1;
639 639
                     mot_val[0       ]= mot_val[2       ]=
640 640
                     mot_val[0+stride]= mot_val[2+stride]= 0;
... ...
@@ -660,11 +660,11 @@ try_again:
660 660
                             my = h263_decode_motion(s, pred_y, s->f_code);
661 661
                             if (my >= 0xffff)
662 662
                                 return -1;
663
-                            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
663
+                            s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
664 664
                         } else {
665 665
                             mx = get_amv(s, 0);
666 666
                             my = get_amv(s, 1);
667
-                            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
667
+                            s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
668 668
                         }
669 669
 
670 670
                         mot_val[0       ]= mot_val[2       ] =
... ...
@@ -673,7 +673,7 @@ try_again:
673 673
                         mot_val[1+stride]= mot_val[3+stride]= my;
674 674
                     } else {
675 675
                         int i;
676
-                        s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
676
+                        s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
677 677
                         for(i=0;i<4;i++) {
678 678
                             int16_t *mot_val= h263_pred_motion(s, i, 0, &pred_x, &pred_y);
679 679
                             mx = h263_decode_motion(s, pred_x, s->f_code);
... ...
@@ -725,9 +725,9 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
725 725
                 }
726 726
 
727 727
                 s->cbp_table[xy]|= cbpy<<2;
728
-                s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
728
+                s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
729 729
             }else{ /* P || S_TYPE */
730
-                if(IS_INTRA(s->current_picture.mb_type[xy])){
730
+                if (IS_INTRA(s->current_picture.f.mb_type[xy])) {
731 731
                     int dir=0,i;
732 732
                     int ac_pred = get_bits1(&s->gb);
733 733
                     int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
... ...
@@ -740,7 +740,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
740 740
                     if(s->cbp_table[xy] & 8) {
741 741
                         ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
742 742
                     }
743
-                    s->current_picture.qscale_table[xy]= s->qscale;
743
+                    s->current_picture.f.qscale_table[xy] = s->qscale;
744 744
 
745 745
                     for(i=0; i<6; i++){
746 746
                         int dc_pred_dir;
... ...
@@ -754,10 +754,10 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
754 754
                     }
755 755
                     s->cbp_table[xy]&= 3; //remove dquant
756 756
                     s->cbp_table[xy]|= cbpy<<2;
757
-                    s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
757
+                    s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
758 758
                     s->pred_dir_table[xy]= dir;
759
-                }else if(IS_SKIP(s->current_picture.mb_type[xy])){
760
-                    s->current_picture.qscale_table[xy]= s->qscale;
759
+                } else if (IS_SKIP(s->current_picture.f.mb_type[xy])) {
760
+                    s->current_picture.f.qscale_table[xy] = s->qscale;
761 761
                     s->cbp_table[xy]= 0;
762 762
                 }else{
763 763
                     int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
... ...
@@ -770,7 +770,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
770 770
                     if(s->cbp_table[xy] & 8) {
771 771
                         ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
772 772
                     }
773
-                    s->current_picture.qscale_table[xy]= s->qscale;
773
+                    s->current_picture.f.qscale_table[xy] = s->qscale;
774 774
 
775 775
                     s->cbp_table[xy]&= 3; //remove dquant
776 776
                     s->cbp_table[xy]|= (cbpy^0xf)<<2;
... ...
@@ -1091,20 +1091,20 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
1091 1091
     int cbp, mb_type;
1092 1092
     const int xy= s->mb_x + s->mb_y*s->mb_stride;
1093 1093
 
1094
-    mb_type= s->current_picture.mb_type[xy];
1094
+    mb_type = s->current_picture.f.mb_type[xy];
1095 1095
     cbp = s->cbp_table[xy];
1096 1096
 
1097 1097
     s->use_intra_dc_vlc= s->qscale < s->intra_dc_threshold;
1098 1098
 
1099
-    if(s->current_picture.qscale_table[xy] != s->qscale){
1100
-        ff_set_qscale(s, s->current_picture.qscale_table[xy] );
1099
+    if (s->current_picture.f.qscale_table[xy] != s->qscale) {
1100
+        ff_set_qscale(s, s->current_picture.f.qscale_table[xy]);
1101 1101
     }
1102 1102
 
1103 1103
     if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
1104 1104
         int i;
1105 1105
         for(i=0; i<4; i++){
1106
-            s->mv[0][i][0] = s->current_picture.motion_val[0][ s->block_index[i] ][0];
1107
-            s->mv[0][i][1] = s->current_picture.motion_val[0][ s->block_index[i] ][1];
1106
+            s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0];
1107
+            s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1];
1108 1108
         }
1109 1109
         s->mb_intra = IS_INTRA(mb_type);
1110 1110
 
... ...
@@ -1122,7 +1122,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
1122 1122
                 s->mb_skipped = 1;
1123 1123
             }
1124 1124
         }else if(s->mb_intra){
1125
-            s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
1125
+            s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]);
1126 1126
         }else if(!s->mb_intra){
1127 1127
 //            s->mcsel= 0; //FIXME do we need to init that
1128 1128
 
... ...
@@ -1135,7 +1135,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
1135 1135
         }
1136 1136
     } else { /* I-Frame */
1137 1137
         s->mb_intra = 1;
1138
-        s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
1138
+        s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]);
1139 1139
     }
1140 1140
 
1141 1141
     if (!IS_SKIP(mb_type)) {
... ...
@@ -1188,14 +1188,14 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1188 1188
                 s->mv_dir = MV_DIR_FORWARD;
1189 1189
                 s->mv_type = MV_TYPE_16X16;
1190 1190
                 if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
1191
-                    s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
1191
+                    s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
1192 1192
                     s->mcsel=1;
1193 1193
                     s->mv[0][0][0]= get_amv(s, 0);
1194 1194
                     s->mv[0][0][1]= get_amv(s, 1);
1195 1195
 
1196 1196
                     s->mb_skipped = 0;
1197 1197
                 }else{
1198
-                    s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
1198
+                    s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
1199 1199
                     s->mcsel=0;
1200 1200
                     s->mv[0][0][0] = 0;
1201 1201
                     s->mv[0][0][1] = 0;
... ...
@@ -1230,7 +1230,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1230 1230
         s->mv_dir = MV_DIR_FORWARD;
1231 1231
         if ((cbpc & 16) == 0) {
1232 1232
             if(s->mcsel){
1233
-                s->current_picture.mb_type[xy]= MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
1233
+                s->current_picture.f.mb_type[xy] = MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
1234 1234
                 /* 16x16 global motion prediction */
1235 1235
                 s->mv_type = MV_TYPE_16X16;
1236 1236
                 mx= get_amv(s, 0);
... ...
@@ -1238,7 +1238,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1238 1238
                 s->mv[0][0][0] = mx;
1239 1239
                 s->mv[0][0][1] = my;
1240 1240
             }else if((!s->progressive_sequence) && get_bits1(&s->gb)){
1241
-                s->current_picture.mb_type[xy]= MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED;
1241
+                s->current_picture.f.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED;
1242 1242
                 /* 16x8 field motion prediction */
1243 1243
                 s->mv_type= MV_TYPE_FIELD;
1244 1244
 
... ...
@@ -1260,7 +1260,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1260 1260
                     s->mv[0][i][1] = my;
1261 1261
                 }
1262 1262
             }else{
1263
-                s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
1263
+                s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
1264 1264
                 /* 16x16 motion prediction */
1265 1265
                 s->mv_type = MV_TYPE_16X16;
1266 1266
                 h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
... ...
@@ -1277,7 +1277,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1277 1277
                 s->mv[0][0][1] = my;
1278 1278
             }
1279 1279
         } else {
1280
-            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
1280
+            s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
1281 1281
             s->mv_type = MV_TYPE_8X8;
1282 1282
             for(i=0;i<4;i++) {
1283 1283
                 mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
... ...
@@ -1314,7 +1314,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1314 1314
         }
1315 1315
 
1316 1316
         /* if we skipped it in the future P Frame than skip it now too */
1317
-        s->mb_skipped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
1317
+        s->mb_skipped = s->next_picture.f.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
1318 1318
 
1319 1319
         if(s->mb_skipped){
1320 1320
                 /* skip mb */
... ...
@@ -1327,7 +1327,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1327 1327
             s->mv[0][0][1] = 0;
1328 1328
             s->mv[1][0][0] = 0;
1329 1329
             s->mv[1][0][1] = 0;
1330
-            s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
1330
+            s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
1331 1331
             goto end;
1332 1332
         }
1333 1333
 
... ...
@@ -1433,7 +1433,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1433 1433
             s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
1434 1434
             mb_type |= ff_mpeg4_set_direct_mv(s, mx, my);
1435 1435
         }
1436
-        s->current_picture.mb_type[xy]= mb_type;
1436
+        s->current_picture.f.mb_type[xy] = mb_type;
1437 1437
     } else { /* I-Frame */
1438 1438
         do{
1439 1439
             cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
... ...
@@ -1448,9 +1448,9 @@ static int mpeg4_decode_mb(MpegEncContext *s,
1448 1448
 intra:
1449 1449
         s->ac_pred = get_bits1(&s->gb);
1450 1450
         if(s->ac_pred)
1451
-            s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED;
1451
+            s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
1452 1452
         else
1453
-            s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
1453
+            s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
1454 1454
 
1455 1455
         cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1456 1456
         if(cbpy<0){
... ...
@@ -1496,7 +1496,7 @@ end:
1496 1496
                                         (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0);
1497 1497
             }
1498 1498
 
1499
-            if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta])
1499
+            if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta])
1500 1500
                 return SLICE_OK;
1501 1501
             return SLICE_END;
1502 1502
         }
... ...
@@ -1965,11 +1965,12 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
1965 1965
     }
1966 1966
 
1967 1967
     if(s->avctx->time_base.num)
1968
-        s->current_picture_ptr->pts= (s->time + s->avctx->time_base.num/2) / s->avctx->time_base.num;
1968
+        s->current_picture_ptr->f.pts = (s->time + s->avctx->time_base.num / 2) / s->avctx->time_base.num;
1969 1969
     else
1970
-        s->current_picture_ptr->pts= AV_NOPTS_VALUE;
1970
+        s->current_picture_ptr->f.pts = AV_NOPTS_VALUE;
1971 1971
     if(s->avctx->debug&FF_DEBUG_PTS)
1972
-        av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n", s->current_picture_ptr->pts);
1972
+        av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n",
1973
+               s->current_picture_ptr->f.pts);
1973 1974
 
1974 1975
     check_marker(gb, "before vop_coded");
1975 1976
 
... ...
@@ -124,7 +124,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], const
124 124
 {
125 125
     int score= 0;
126 126
     int i, n;
127
-    int8_t * const qscale_table= s->current_picture.qscale_table;
127
+    int8_t * const qscale_table = s->current_picture.f.qscale_table;
128 128
 
129 129
     memcpy(zigzag_last_index, s->block_last_index, sizeof(int)*6);
130 130
 
... ...
@@ -201,7 +201,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], const
201 201
  */
202 202
 void ff_clean_mpeg4_qscales(MpegEncContext *s){
203 203
     int i;
204
-    int8_t * const qscale_table= s->current_picture.qscale_table;
204
+    int8_t * const qscale_table = s->current_picture.f.qscale_table;
205 205
 
206 206
     ff_clean_h263_qscales(s);
207 207
 
... ...
@@ -457,7 +457,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
457 457
             assert(mb_type>=0);
458 458
 
459 459
             /* nothing to do if this MB was skipped in the next P Frame */
460
-            if(s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]){ //FIXME avoid DCT & ...
460
+            if (s->next_picture.f.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]) { //FIXME avoid DCT & ...
461 461
                 s->skip_count++;
462 462
                 s->mv[0][0][0]=
463 463
                 s->mv[0][0][1]=
... ...
@@ -587,7 +587,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
587 587
                     y= s->mb_y*16;
588 588
 
589 589
                     offset= x + y*s->linesize;
590
-                    p_pic= s->new_picture.data[0] + offset;
590
+                    p_pic = s->new_picture.f.data[0] + offset;
591 591
 
592 592
                     s->mb_skipped=1;
593 593
                     for(i=0; i<s->max_b_frames; i++){
... ...
@@ -595,10 +595,11 @@ void mpeg4_encode_mb(MpegEncContext * s,
595 595
                         int diff;
596 596
                         Picture *pic= s->reordered_input_picture[i+1];
597 597
 
598
-                        if(pic==NULL || pic->pict_type!=AV_PICTURE_TYPE_B) break;
598
+                        if (pic == NULL || pic->f.pict_type != AV_PICTURE_TYPE_B)
599
+                            break;
599 600
 
600
-                        b_pic= pic->data[0] + offset;
601
-                        if(pic->type != FF_BUFFER_TYPE_SHARED)
601
+                        b_pic = pic->f.data[0] + offset;
602
+                        if (pic->f.type != FF_BUFFER_TYPE_SHARED)
602 603
                             b_pic+= INPLACE_OFFSET;
603 604
 
604 605
                         if(x+16 > s->width || y+16 > s->height){
... ...
@@ -716,8 +717,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
716 716
                     /* motion vectors: 8x8 mode*/
717 717
                     h263_pred_motion(s, i, 0, &pred_x, &pred_y);
718 718
 
719
-                    ff_h263_encode_motion_vector(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x,
720
-                                                    s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
719
+                    ff_h263_encode_motion_vector(s, s->current_picture.f.motion_val[0][ s->block_index[i] ][0] - pred_x,
720
+                                                    s->current_picture.f.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
721 721
                 }
722 722
             }
723 723
 
... ...
@@ -826,9 +827,9 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){
826 826
     put_bits(&s->pb, 16, 0);
827 827
     put_bits(&s->pb, 16, GOP_STARTCODE);
828 828
 
829
-    time= s->current_picture_ptr->pts;
829
+    time = s->current_picture_ptr->f.pts;
830 830
     if(s->reordered_input_picture[1])
831
-        time= FFMIN(time, s->reordered_input_picture[1]->pts);
831
+        time = FFMIN(time, s->reordered_input_picture[1]->f.pts);
832 832
     time= time*s->avctx->time_base.num;
833 833
     s->last_time_base= FFUDIV(time, s->avctx->time_base.den);
834 834
 
... ...
@@ -1036,7 +1037,7 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
1036 1036
     }
1037 1037
     put_bits(&s->pb, 3, 0);     /* intra dc VLC threshold */
1038 1038
     if(!s->progressive_sequence){
1039
-         put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
1039
+         put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first);
1040 1040
          put_bits(&s->pb, 1, s->alternate_scan);
1041 1041
     }
1042 1042
     //FIXME sprite stuff
... ...
@@ -198,7 +198,7 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
198 198
 
199 199
 void ff_copy_picture(Picture *dst, Picture *src){
200 200
     *dst = *src;
201
-    dst->type= FF_BUFFER_TYPE_COPY;
201
+    dst->f.type= FF_BUFFER_TYPE_COPY;
202 202
 }
203 203
 
204 204
 /**
... ...
@@ -207,7 +207,7 @@ void ff_copy_picture(Picture *dst, Picture *src){
207 207
 static void free_frame_buffer(MpegEncContext *s, Picture *pic)
208 208
 {
209 209
     ff_thread_release_buffer(s->avctx, (AVFrame*)pic);
210
-    av_freep(&pic->hwaccel_picture_private);
210
+    av_freep(&pic->f.hwaccel_picture_private);
211 211
 }
212 212
 
213 213
 /**
... ...
@@ -220,8 +220,8 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
220 220
     if (s->avctx->hwaccel) {
221 221
         assert(!pic->hwaccel_picture_private);
222 222
         if (s->avctx->hwaccel->priv_data_size) {
223
-            pic->hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
224
-            if (!pic->hwaccel_picture_private) {
223
+            pic->f.hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
224
+            if (!pic->f.hwaccel_picture_private) {
225 225
                 av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
226 226
                 return -1;
227 227
             }
... ...
@@ -230,19 +230,20 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
230 230
 
231 231
     r = ff_thread_get_buffer(s->avctx, (AVFrame*)pic);
232 232
 
233
-    if (r<0 || !pic->age || !pic->type || !pic->data[0]) {
234
-        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
235
-        av_freep(&pic->hwaccel_picture_private);
233
+    if (r < 0 || !pic->f.age || !pic->f.type || !pic->f.data[0]) {
234
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n",
235
+               r, pic->f.age, pic->f.type, pic->f.data[0]);
236
+        av_freep(&pic->f.hwaccel_picture_private);
236 237
         return -1;
237 238
     }
238 239
 
239
-    if (s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])) {
240
+    if (s->linesize && (s->linesize != pic->f.linesize[0] || s->uvlinesize != pic->f.linesize[1])) {
240 241
         av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
241 242
         free_frame_buffer(s, pic);
242 243
         return -1;
243 244
     }
244 245
 
245
-    if (pic->linesize[1] != pic->linesize[2]) {
246
+    if (pic->f.linesize[1] != pic->f.linesize[2]) {
246 247
         av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
247 248
         free_frame_buffer(s, pic);
248 249
         return -1;
... ...
@@ -264,59 +265,59 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
264 264
     int r= -1;
265 265
 
266 266
     if(shared){
267
-        assert(pic->data[0]);
267
+        assert(pic->f.data[0]);
268 268
         assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
269
-        pic->type= FF_BUFFER_TYPE_SHARED;
269
+        pic->f.type = FF_BUFFER_TYPE_SHARED;
270 270
     }else{
271
-        assert(!pic->data[0]);
271
+        assert(!pic->f.data[0]);
272 272
 
273 273
         if (alloc_frame_buffer(s, pic) < 0)
274 274
             return -1;
275 275
 
276
-        s->linesize  = pic->linesize[0];
277
-        s->uvlinesize= pic->linesize[1];
276
+        s->linesize   = pic->f.linesize[0];
277
+        s->uvlinesize = pic->f.linesize[1];
278 278
     }
279 279
 
280
-    if(pic->qscale_table==NULL){
280
+    if (pic->f.qscale_table == NULL) {
281 281
         if (s->encoding) {
282 282
             FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_var   , mb_array_size * sizeof(int16_t)  , fail)
283 283
             FF_ALLOCZ_OR_GOTO(s->avctx, pic->mc_mb_var, mb_array_size * sizeof(int16_t)  , fail)
284 284
             FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_mean  , mb_array_size * sizeof(int8_t )  , fail)
285 285
         }
286 286
 
287
-        FF_ALLOCZ_OR_GOTO(s->avctx, pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2, fail) //the +2 is for the slice end check
287
+        FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.mbskip_table, mb_array_size * sizeof(uint8_t) + 2, fail) //the +2 is for the slice end check
288 288
         FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base , (big_mb_num + s->mb_stride) * sizeof(uint8_t)  , fail)
289 289
         FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t), fail)
290
-        pic->mb_type= pic->mb_type_base + 2*s->mb_stride+1;
291
-        pic->qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1;
290
+        pic->f.mb_type = pic->mb_type_base + 2*s->mb_stride + 1;
291
+        pic->f.qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1;
292 292
         if(s->out_format == FMT_H264){
293 293
             for(i=0; i<2; i++){
294 294
                 FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b4_array_size+4)  * sizeof(int16_t), fail)
295
-                pic->motion_val[i]= pic->motion_val_base[i]+4;
296
-                FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
295
+                pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
296
+                FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
297 297
             }
298
-            pic->motion_subsample_log2= 2;
298
+            pic->f.motion_subsample_log2 = 2;
299 299
         }else if(s->out_format == FMT_H263 || s->encoding || (s->avctx->debug&FF_DEBUG_MV) || (s->avctx->debug_mv)){
300 300
             for(i=0; i<2; i++){
301 301
                 FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail)
302
-                pic->motion_val[i]= pic->motion_val_base[i]+4;
303
-                FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
302
+                pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
303
+                FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
304 304
             }
305
-            pic->motion_subsample_log2= 3;
305
+            pic->f.motion_subsample_log2 = 3;
306 306
         }
307 307
         if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
308
-            FF_ALLOCZ_OR_GOTO(s->avctx, pic->dct_coeff, 64 * mb_array_size * sizeof(DCTELEM)*6, fail)
308
+            FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.dct_coeff, 64 * mb_array_size * sizeof(DCTELEM) * 6, fail)
309 309
         }
310
-        pic->qstride= s->mb_stride;
311
-        FF_ALLOCZ_OR_GOTO(s->avctx, pic->pan_scan , 1 * sizeof(AVPanScan), fail)
310
+        pic->f.qstride = s->mb_stride;
311
+        FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.pan_scan , 1 * sizeof(AVPanScan), fail)
312 312
     }
313 313
 
314 314
     /* It might be nicer if the application would keep track of these
315 315
      * but it would require an API change. */
316 316
     memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
317 317
     s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type;
318
-    if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == AV_PICTURE_TYPE_B)
319
-        pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
318
+    if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B)
319
+        pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
320 320
     pic->owner2 = NULL;
321 321
 
322 322
     return 0;
... ...
@@ -332,30 +333,30 @@ fail: //for the FF_ALLOCZ_OR_GOTO macro
332 332
 static void free_picture(MpegEncContext *s, Picture *pic){
333 333
     int i;
334 334
 
335
-    if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){
335
+    if (pic->f.data[0] && pic->f.type != FF_BUFFER_TYPE_SHARED) {
336 336
         free_frame_buffer(s, pic);
337 337
     }
338 338
 
339 339
     av_freep(&pic->mb_var);
340 340
     av_freep(&pic->mc_mb_var);
341 341
     av_freep(&pic->mb_mean);
342
-    av_freep(&pic->mbskip_table);
342
+    av_freep(&pic->f.mbskip_table);
343 343
     av_freep(&pic->qscale_table_base);
344 344
     av_freep(&pic->mb_type_base);
345
-    av_freep(&pic->dct_coeff);
346
-    av_freep(&pic->pan_scan);
347
-    pic->mb_type= NULL;
345
+    av_freep(&pic->f.dct_coeff);
346
+    av_freep(&pic->f.pan_scan);
347
+    pic->f.mb_type = NULL;
348 348
     for(i=0; i<2; i++){
349 349
         av_freep(&pic->motion_val_base[i]);
350
-        av_freep(&pic->ref_index[i]);
350
+        av_freep(&pic->f.ref_index[i]);
351 351
     }
352 352
 
353
-    if(pic->type == FF_BUFFER_TYPE_SHARED){
353
+    if (pic->f.type == FF_BUFFER_TYPE_SHARED) {
354 354
         for(i=0; i<4; i++){
355
-            pic->base[i]=
356
-            pic->data[i]= NULL;
355
+            pic->f.base[i] =
356
+            pic->f.data[i] = NULL;
357 357
         }
358
-        pic->type= 0;
358
+        pic->f.type = 0;
359 359
     }
360 360
 }
361 361
 
... ...
@@ -526,7 +527,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src
526 526
 
527 527
     if(!s1->first_field){
528 528
         s->last_pict_type= s1->pict_type;
529
-        if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->quality;
529
+        if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->f.quality;
530 530
 
531 531
         if(s1->pict_type!=FF_B_TYPE){
532 532
             s->last_non_b_pict_type= s1->pict_type;
... ...
@@ -960,7 +961,7 @@ void ff_release_unused_pictures(MpegEncContext *s, int remove_current)
960 960
 
961 961
     /* release non reference frames */
962 962
     for(i=0; i<s->picture_count; i++){
963
-        if(s->picture[i].data[0] && !s->picture[i].reference
963
+        if (s->picture[i].f.data[0] && !s->picture[i].f.reference
964 964
            && (!s->picture[i].owner2 || s->picture[i].owner2 == s)
965 965
            && (remove_current || &s->picture[i] != s->current_picture_ptr)
966 966
            /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
... ...
@@ -974,14 +975,17 @@ int ff_find_unused_picture(MpegEncContext *s, int shared){
974 974
 
975 975
     if(shared){
976 976
         for(i=s->picture_range_start; i<s->picture_range_end; i++){
977
-            if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i;
977
+            if (s->picture[i].f.data[0] == NULL && s->picture[i].f.type == 0)
978
+                return i;
978 979
         }
979 980
     }else{
980 981
         for(i=s->picture_range_start; i<s->picture_range_end; i++){
981
-            if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME
982
+            if (s->picture[i].f.data[0] == NULL && s->picture[i].f.type != 0)
983
+                return i; //FIXME
982 984
         }
983 985
         for(i=s->picture_range_start; i<s->picture_range_end; i++){
984
-            if(s->picture[i].data[0]==NULL) return i;
986
+            if (s->picture[i].f.data[0] == NULL)
987
+                return i;
985 988
         }
986 989
     }
987 990
 
... ...
@@ -1030,7 +1034,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1030 1030
     assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
1031 1031
 
1032 1032
     /* mark&release old frames */
1033
-    if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
1033
+    if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->f.data[0]) {
1034 1034
       if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
1035 1035
           free_frame_buffer(s, s->last_picture_ptr);
1036 1036
 
... ...
@@ -1038,7 +1042,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1038 1038
         /* if(mpeg124/h263) */
1039 1039
         if(!s->encoding){
1040 1040
             for(i=0; i<s->picture_count; i++){
1041
-                if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){
1041
+                if (s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) {
1042 1042
                     av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
1043 1043
                     free_frame_buffer(s, &s->picture[i]);
1044 1044
                 }
... ...
@@ -1050,41 +1054,41 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1050 1050
     if(!s->encoding){
1051 1051
         ff_release_unused_pictures(s, 1);
1052 1052
 
1053
-        if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL)
1053
+        if (s->current_picture_ptr && s->current_picture_ptr->f.data[0] == NULL)
1054 1054
             pic= s->current_picture_ptr; //we already have a unused image (maybe it was set before reading the header)
1055 1055
         else{
1056 1056
             i= ff_find_unused_picture(s, 0);
1057 1057
             pic= &s->picture[i];
1058 1058
         }
1059 1059
 
1060
-        pic->reference= 0;
1060
+        pic->f.reference = 0;
1061 1061
         if (!s->dropable){
1062 1062
             if (s->codec_id == CODEC_ID_H264)
1063
-                pic->reference = s->picture_structure;
1063
+                pic->f.reference = s->picture_structure;
1064 1064
             else if (s->pict_type != AV_PICTURE_TYPE_B)
1065
-                pic->reference = 3;
1065
+                pic->f.reference = 3;
1066 1066
         }
1067 1067
 
1068
-        pic->coded_picture_number= s->coded_picture_number++;
1068
+        pic->f.coded_picture_number = s->coded_picture_number++;
1069 1069
 
1070 1070
         if(ff_alloc_picture(s, pic, 0) < 0)
1071 1071
             return -1;
1072 1072
 
1073 1073
         s->current_picture_ptr= pic;
1074 1074
         //FIXME use only the vars from current_pic
1075
-        s->current_picture_ptr->top_field_first= s->top_field_first;
1075
+        s->current_picture_ptr->f.top_field_first = s->top_field_first;
1076 1076
         if(s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) {
1077 1077
             if(s->picture_structure != PICT_FRAME)
1078
-                s->current_picture_ptr->top_field_first= (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
1078
+                s->current_picture_ptr->f.top_field_first = (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
1079 1079
         }
1080
-        s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence;
1081
-        s->current_picture_ptr->field_picture= s->picture_structure != PICT_FRAME;
1080
+        s->current_picture_ptr->f.interlaced_frame = !s->progressive_frame && !s->progressive_sequence;
1081
+        s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
1082 1082
     }
1083 1083
 
1084
-    s->current_picture_ptr->pict_type= s->pict_type;
1084
+    s->current_picture_ptr->f.pict_type = s->pict_type;
1085 1085
 //    if(s->flags && CODEC_FLAG_QSCALE)
1086 1086
   //      s->current_picture_ptr->quality= s->new_picture_ptr->quality;
1087
-    s->current_picture_ptr->key_frame= s->pict_type == AV_PICTURE_TYPE_I;
1087
+    s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
1088 1088
 
1089 1089
     ff_copy_picture(&s->current_picture, s->current_picture_ptr);
1090 1090
 
... ...
@@ -1094,13 +1098,13 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1094 1094
             s->next_picture_ptr= s->current_picture_ptr;
1095 1095
     }
1096 1096
 /*    av_log(s->avctx, AV_LOG_DEBUG, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
1097
-        s->last_picture_ptr    ? s->last_picture_ptr->data[0] : NULL,
1098
-        s->next_picture_ptr    ? s->next_picture_ptr->data[0] : NULL,
1099
-        s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL,
1097
+        s->last_picture_ptr    ? s->last_picture_ptr->f.data[0]    : NULL,
1098
+        s->next_picture_ptr    ? s->next_picture_ptr->f.data[0]    : NULL,
1099
+        s->current_picture_ptr ? s->current_picture_ptr->f.data[0] : NULL,
1100 1100
         s->pict_type, s->dropable);*/
1101 1101
 
1102 1102
     if(s->codec_id != CODEC_ID_H264){
1103
-        if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) &&
1103
+        if ((s->last_picture_ptr == NULL || s->last_picture_ptr->f.data[0] == NULL) &&
1104 1104
            (s->pict_type!=AV_PICTURE_TYPE_I || s->picture_structure != PICT_FRAME)){
1105 1105
             if (s->pict_type != AV_PICTURE_TYPE_I)
1106 1106
                 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
... ...
@@ -1115,7 +1119,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1115 1115
             ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0);
1116 1116
             ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 1);
1117 1117
         }
1118
-        if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==AV_PICTURE_TYPE_B){
1118
+        if ((s->next_picture_ptr == NULL || s->next_picture_ptr->f.data[0] == NULL) && s->pict_type == AV_PICTURE_TYPE_B) {
1119 1119
             /* Allocate a dummy frame */
1120 1120
             i= ff_find_unused_picture(s, 0);
1121 1121
             s->next_picture_ptr= &s->picture[i];
... ...
@@ -1129,17 +1133,17 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1129 1129
     if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr);
1130 1130
     if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr);
1131 1131
 
1132
-    assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
1132
+    assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && s->last_picture_ptr->f.data[0]));
1133 1133
 
1134 1134
     if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){
1135 1135
         int i;
1136 1136
         for(i=0; i<4; i++){
1137 1137
             if(s->picture_structure == PICT_BOTTOM_FIELD){
1138
-                 s->current_picture.data[i] += s->current_picture.linesize[i];
1138
+                 s->current_picture.f.data[i] += s->current_picture.f.linesize[i];
1139 1139
             }
1140
-            s->current_picture.linesize[i] *= 2;
1141
-            s->last_picture.linesize[i] *=2;
1142
-            s->next_picture.linesize[i] *=2;
1140
+            s->current_picture.f.linesize[i] *= 2;
1141
+            s->last_picture.f.linesize[i]    *= 2;
1142
+            s->next_picture.f.linesize[i]    *= 2;
1143 1143
         }
1144 1144
     }
1145 1145
 
... ...
@@ -1182,18 +1186,18 @@ void MPV_frame_end(MpegEncContext *s)
1182 1182
        && !s->avctx->hwaccel
1183 1183
        && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
1184 1184
        && s->unrestricted_mv
1185
-       && s->current_picture.reference
1185
+       && s->current_picture.f.reference
1186 1186
        && !s->intra_only
1187 1187
        && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
1188 1188
             int hshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_w;
1189 1189
             int vshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_h;
1190
-            s->dsp.draw_edges(s->current_picture.data[0], s->linesize  ,
1190
+            s->dsp.draw_edges(s->current_picture.f.data[0], s->linesize,
1191 1191
                               s->h_edge_pos             , s->v_edge_pos,
1192 1192
                               EDGE_WIDTH        , EDGE_WIDTH        , EDGE_TOP | EDGE_BOTTOM);
1193
-            s->dsp.draw_edges(s->current_picture.data[1], s->uvlinesize,
1193
+            s->dsp.draw_edges(s->current_picture.f.data[1], s->uvlinesize,
1194 1194
                               s->h_edge_pos>>hshift, s->v_edge_pos>>vshift,
1195 1195
                               EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, EDGE_TOP | EDGE_BOTTOM);
1196
-            s->dsp.draw_edges(s->current_picture.data[2], s->uvlinesize,
1196
+            s->dsp.draw_edges(s->current_picture.f.data[2], s->uvlinesize,
1197 1197
                               s->h_edge_pos>>hshift, s->v_edge_pos>>vshift,
1198 1198
                               EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, EDGE_TOP | EDGE_BOTTOM);
1199 1199
     }
... ...
@@ -1201,14 +1205,14 @@ void MPV_frame_end(MpegEncContext *s)
1201 1201
     emms_c();
1202 1202
 
1203 1203
     s->last_pict_type    = s->pict_type;
1204
-    s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality;
1204
+    s->last_lambda_for[s->pict_type] = s->current_picture_ptr->f.quality;
1205 1205
     if(s->pict_type!=AV_PICTURE_TYPE_B){
1206 1206
         s->last_non_b_pict_type= s->pict_type;
1207 1207
     }
1208 1208
 #if 0
1209 1209
         /* copy back current_picture variables */
1210 1210
     for(i=0; i<MAX_PICTURE_COUNT; i++){
1211
-        if(s->picture[i].data[0] == s->current_picture.data[0]){
1211
+        if(s->picture[i].f.data[0] == s->current_picture.f.data[0]){
1212 1212
             s->picture[i]= s->current_picture;
1213 1213
             break;
1214 1214
         }
... ...
@@ -1219,7 +1223,7 @@ void MPV_frame_end(MpegEncContext *s)
1219 1219
     if(s->encoding){
1220 1220
         /* release non-reference frames */
1221 1221
         for(i=0; i<s->picture_count; i++){
1222
-            if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
1222
+            if (s->picture[i].f.data[0] && !s->picture[i].f.reference /*&& s->picture[i].type != FF_BUFFER_TYPE_SHARED*/) {
1223 1223
                 free_frame_buffer(s, &s->picture[i]);
1224 1224
             }
1225 1225
         }
... ...
@@ -1232,7 +1236,7 @@ void MPV_frame_end(MpegEncContext *s)
1232 1232
 #endif
1233 1233
     s->avctx->coded_frame= (AVFrame*)s->current_picture_ptr;
1234 1234
 
1235
-    if (s->codec_id != CODEC_ID_H264 && s->current_picture.reference) {
1235
+    if (s->codec_id != CODEC_ID_H264 && s->current_picture.f.reference) {
1236 1236
         ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_height-1, 0);
1237 1237
     }
1238 1238
 }
... ...
@@ -1633,8 +1637,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
1633 1633
     const int s_mask= (2<<lowres)-1;
1634 1634
     const int h_edge_pos = s->h_edge_pos >> lowres;
1635 1635
     const int v_edge_pos = s->v_edge_pos >> lowres;
1636
-    linesize   = s->current_picture.linesize[0] << field_based;
1637
-    uvlinesize = s->current_picture.linesize[1] << field_based;
1636
+    linesize   = s->current_picture.f.linesize[0] << field_based;
1637
+    uvlinesize = s->current_picture.f.linesize[1] << field_based;
1638 1638
 
1639 1639
     if(s->quarter_sample){ //FIXME obviously not perfect but qpel will not work in lowres anyway
1640 1640
         motion_x/=2;
... ...
@@ -1708,7 +1712,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
1708 1708
             }
1709 1709
     }
1710 1710
 
1711
-    if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
1711
+    if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.f.data
1712 1712
         dest_y += s->linesize;
1713 1713
         dest_cb+= s->uvlinesize;
1714 1714
         dest_cr+= s->uvlinesize;
... ...
@@ -1850,7 +1854,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
1850 1850
                         s->mv[dir][1][0], s->mv[dir][1][1], block_s, mb_y);
1851 1851
         } else {
1852 1852
             if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){
1853
-                ref_picture= s->current_picture_ptr->data;
1853
+                ref_picture = s->current_picture_ptr->f.data;
1854 1854
             }
1855 1855
 
1856 1856
             mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
... ...
@@ -1866,7 +1870,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
1866 1866
             if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){
1867 1867
                 ref2picture= ref_picture;
1868 1868
             }else{
1869
-                ref2picture= s->current_picture_ptr->data;
1869
+                ref2picture = s->current_picture_ptr->f.data;
1870 1870
             }
1871 1871
 
1872 1872
             mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
... ...
@@ -1903,7 +1907,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
1903 1903
 
1904 1904
                 //opposite parity is always in the same frame if this is second field
1905 1905
                 if(!s->first_field){
1906
-                    ref_picture = s->current_picture_ptr->data;
1906
+                    ref_picture = s->current_picture_ptr->f.data;
1907 1907
                 }
1908 1908
             }
1909 1909
         }
... ...
@@ -2032,7 +2036,7 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2032 2032
     if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
2033 2033
        /* save DCT coefficients */
2034 2034
        int i,j;
2035
-       DCTELEM *dct = &s->current_picture.dct_coeff[mb_xy*64*6];
2035
+       DCTELEM *dct = &s->current_picture.f.dct_coeff[mb_xy * 64 * 6];
2036 2036
        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
2037 2037
        for(i=0; i<6; i++){
2038 2038
            for(j=0; j<64; j++){
... ...
@@ -2043,7 +2047,7 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2043 2043
        }
2044 2044
     }
2045 2045
 
2046
-    s->current_picture.qscale_table[mb_xy]= s->qscale;
2046
+    s->current_picture.f.qscale_table[mb_xy] = s->qscale;
2047 2047
 
2048 2048
     /* update DC predictors for P macroblocks */
2049 2049
     if (!s->mb_intra) {
... ...
@@ -2064,8 +2068,8 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2064 2064
         int dct_linesize, dct_offset;
2065 2065
         op_pixels_func (*op_pix)[4];
2066 2066
         qpel_mc_func (*op_qpix)[16];
2067
-        const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
2068
-        const int uvlinesize= s->current_picture.linesize[1];
2067
+        const int linesize   = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics
2068
+        const int uvlinesize = s->current_picture.f.linesize[1];
2069 2069
         const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
2070 2070
         const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
2071 2071
 
... ...
@@ -2073,7 +2077,7 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2073 2073
         /* skip only during decoding as we might trash the buffers during encoding a bit */
2074 2074
         if(!s->encoding){
2075 2075
             uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
2076
-            const int age= s->current_picture.age;
2076
+            const int age = s->current_picture.f.age;
2077 2077
 
2078 2078
             assert(age);
2079 2079
 
... ...
@@ -2085,10 +2089,10 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2085 2085
                 if(*mbskip_ptr >99) *mbskip_ptr= 99;
2086 2086
 
2087 2087
                 /* if previous was skipped too, then nothing to do !  */
2088
-                if (*mbskip_ptr >= age && s->current_picture.reference){
2088
+                if (*mbskip_ptr >= age && s->current_picture.f.reference){
2089 2089
                     return;
2090 2090
                 }
2091
-            } else if(!s->current_picture.reference){
2091
+            } else if(!s->current_picture.f.reference) {
2092 2092
                 (*mbskip_ptr) ++; /* increase counter so the age can be compared cleanly */
2093 2093
                 if(*mbskip_ptr >99) *mbskip_ptr= 99;
2094 2094
             } else{
... ...
@@ -2127,11 +2131,11 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2127 2127
                     h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab;
2128 2128
 
2129 2129
                     if (s->mv_dir & MV_DIR_FORWARD) {
2130
-                        MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix);
2130
+                        MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix);
2131 2131
                         op_pix = s->dsp.avg_h264_chroma_pixels_tab;
2132 2132
                     }
2133 2133
                     if (s->mv_dir & MV_DIR_BACKWARD) {
2134
-                        MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix);
2134
+                        MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix);
2135 2135
                     }
2136 2136
                 }else{
2137 2137
                     op_qpix= s->me.qpel_put;
... ...
@@ -2141,12 +2145,12 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
2141 2141
                         op_pix = s->dsp.put_no_rnd_pixels_tab;
2142 2142
                     }
2143 2143
                     if (s->mv_dir & MV_DIR_FORWARD) {
2144
-                        MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
2144
+                        MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix);
2145 2145
                         op_pix = s->dsp.avg_pixels_tab;
2146 2146
                         op_qpix= s->me.qpel_avg;
2147 2147
                     }
2148 2148
                     if (s->mv_dir & MV_DIR_BACKWARD) {
2149
-                        MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
2149
+                        MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix);
2150 2150
                     }
2151 2151
                 }
2152 2152
             }
... ...
@@ -2295,7 +2299,7 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
2295 2295
     if (!s->avctx->hwaccel
2296 2296
        && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
2297 2297
        && s->unrestricted_mv
2298
-       && s->current_picture.reference
2298
+       && s->current_picture.f.reference
2299 2299
        && !s->intra_only
2300 2300
        && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
2301 2301
         int sides = 0, edge_h;
... ...
@@ -2306,11 +2310,11 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
2306 2306
 
2307 2307
         edge_h= FFMIN(h, s->v_edge_pos - y);
2308 2308
 
2309
-        s->dsp.draw_edges(s->current_picture_ptr->data[0] +  y         *s->linesize  , s->linesize,
2309
+        s->dsp.draw_edges(s->current_picture_ptr->f.data[0] +  y         *s->linesize  , s->linesize,
2310 2310
                           s->h_edge_pos        , edge_h        , EDGE_WIDTH        , EDGE_WIDTH        , sides);
2311
-        s->dsp.draw_edges(s->current_picture_ptr->data[1] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
2311
+        s->dsp.draw_edges(s->current_picture_ptr->f.data[1] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
2312 2312
                           s->h_edge_pos>>hshift, edge_h>>hshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
2313
-        s->dsp.draw_edges(s->current_picture_ptr->data[2] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
2313
+        s->dsp.draw_edges(s->current_picture_ptr->f.data[2] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
2314 2314
                           s->h_edge_pos>>hshift, edge_h>>hshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
2315 2315
     }
2316 2316
 
... ...
@@ -2349,8 +2353,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
2349 2349
 }
2350 2350
 
2351 2351
 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
2352
-    const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
2353
-    const int uvlinesize= s->current_picture.linesize[1];
2352
+    const int linesize   = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics
2353
+    const int uvlinesize = s->current_picture.f.linesize[1];
2354 2354
     const int mb_size= 4 - s->avctx->lowres;
2355 2355
 
2356 2356
     s->block_index[0]= s->b8_stride*(s->mb_y*2    ) - 2 + s->mb_x*2;
... ...
@@ -2361,9 +2365,9 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
2361 2361
     s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
2362 2362
     //block_index is not used by mpeg2, so it is not affected by chroma_format
2363 2363
 
2364
-    s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << mb_size);
2365
-    s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2366
-    s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2364
+    s->dest[0] = s->current_picture.f.data[0] + ((s->mb_x - 1) <<  mb_size);
2365
+    s->dest[1] = s->current_picture.f.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2366
+    s->dest[2] = s->current_picture.f.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2367 2367
 
2368 2368
     if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
2369 2369
     {
... ...
@@ -2388,8 +2392,9 @@ void ff_mpeg_flush(AVCodecContext *avctx){
2388 2388
         return;
2389 2389
 
2390 2390
     for(i=0; i<s->picture_count; i++){
2391
-       if(s->picture[i].data[0] && (   s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
2392
-                                    || s->picture[i].type == FF_BUFFER_TYPE_USER))
2391
+       if (s->picture[i].f.data[0] &&
2392
+           (s->picture[i].f.type == FF_BUFFER_TYPE_INTERNAL ||
2393
+            s->picture[i].f.type == FF_BUFFER_TYPE_USER))
2393 2394
         free_frame_buffer(s, &s->picture[i]);
2394 2395
     }
2395 2396
     s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
... ...
@@ -28,6 +28,7 @@
28 28
 #ifndef AVCODEC_MPEGVIDEO_H
29 29
 #define AVCODEC_MPEGVIDEO_H
30 30
 
31
+#include "avcodec.h"
31 32
 #include "dsputil.h"
32 33
 #include "get_bits.h"
33 34
 #include "put_bits.h"
... ...
@@ -82,7 +83,7 @@ struct MpegEncContext;
82 82
  * Picture.
83 83
  */
84 84
 typedef struct Picture{
85
-    FF_COMMON_FRAME
85
+    struct AVFrame f;
86 86
 
87 87
     /**
88 88
      * halfpel luma planes.
... ...
@@ -255,8 +255,8 @@ if(s->quarter_sample)
255 255
 #endif
256 256
 
257 257
     v_edge_pos = s->v_edge_pos >> field_based;
258
-    linesize   = s->current_picture.linesize[0] << field_based;
259
-    uvlinesize = s->current_picture.linesize[1] << field_based;
258
+    linesize   = s->current_picture.f.linesize[0] << field_based;
259
+    uvlinesize = s->current_picture.f.linesize[1] << field_based;
260 260
 
261 261
     dxy = ((motion_y & 1) << 1) | (motion_x & 1);
262 262
     src_x = s->mb_x* 16               + (motion_x >> 1);
... ...
@@ -657,30 +657,30 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
657 657
 
658 658
         assert(!s->mb_skipped);
659 659
 
660
-        memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy           ], sizeof(int16_t)*4);
661
-        memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
662
-        memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
660
+        memcpy(mv_cache[1][1], s->current_picture.f.motion_val[0][mot_xy             ], sizeof(int16_t) * 4);
661
+        memcpy(mv_cache[2][1], s->current_picture.f.motion_val[0][mot_xy + mot_stride], sizeof(int16_t) * 4);
662
+        memcpy(mv_cache[3][1], s->current_picture.f.motion_val[0][mot_xy + mot_stride], sizeof(int16_t) * 4);
663 663
 
664
-        if(mb_y==0 || IS_INTRA(s->current_picture.mb_type[xy-s->mb_stride])){
664
+        if (mb_y == 0 || IS_INTRA(s->current_picture.f.mb_type[xy - s->mb_stride])) {
665 665
             memcpy(mv_cache[0][1], mv_cache[1][1], sizeof(int16_t)*4);
666 666
         }else{
667
-            memcpy(mv_cache[0][1], s->current_picture.motion_val[0][mot_xy-mot_stride], sizeof(int16_t)*4);
667
+            memcpy(mv_cache[0][1], s->current_picture.f.motion_val[0][mot_xy - mot_stride], sizeof(int16_t) * 4);
668 668
         }
669 669
 
670
-        if(mb_x==0 || IS_INTRA(s->current_picture.mb_type[xy-1])){
670
+        if (mb_x == 0 || IS_INTRA(s->current_picture.f.mb_type[xy - 1])) {
671 671
             AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
672 672
             AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
673 673
         }else{
674
-            AV_COPY32(mv_cache[1][0], s->current_picture.motion_val[0][mot_xy-1]);
675
-            AV_COPY32(mv_cache[2][0], s->current_picture.motion_val[0][mot_xy-1+mot_stride]);
674
+            AV_COPY32(mv_cache[1][0], s->current_picture.f.motion_val[0][mot_xy - 1]);
675
+            AV_COPY32(mv_cache[2][0], s->current_picture.f.motion_val[0][mot_xy - 1 + mot_stride]);
676 676
         }
677 677
 
678
-        if(mb_x+1>=s->mb_width || IS_INTRA(s->current_picture.mb_type[xy+1])){
678
+        if (mb_x + 1 >= s->mb_width || IS_INTRA(s->current_picture.f.mb_type[xy + 1])) {
679 679
             AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
680 680
             AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
681 681
         }else{
682
-            AV_COPY32(mv_cache[1][3], s->current_picture.motion_val[0][mot_xy+2]);
683
-            AV_COPY32(mv_cache[2][3], s->current_picture.motion_val[0][mot_xy+2+mot_stride]);
682
+            AV_COPY32(mv_cache[1][3], s->current_picture.f.motion_val[0][mot_xy + 2]);
683
+            AV_COPY32(mv_cache[2][3], s->current_picture.f.motion_val[0][mot_xy + 2 + mot_stride]);
684 684
         }
685 685
 
686 686
         mx = 0;
... ...
@@ -817,7 +817,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
817 817
             }
818 818
         } else {
819 819
             if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){
820
-                ref_picture= s->current_picture_ptr->data;
820
+                ref_picture = s->current_picture_ptr->f.data;
821 821
             }
822 822
 
823 823
             mpeg_motion(s, dest_y, dest_cb, dest_cr,
... ...
@@ -834,7 +834,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
834 834
                || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){
835 835
                 ref2picture= ref_picture;
836 836
             }else{
837
-                ref2picture= s->current_picture_ptr->data;
837
+                ref2picture = s->current_picture_ptr->f.data;
838 838
             }
839 839
 
840 840
             mpeg_motion(s, dest_y, dest_cb, dest_cr,
... ...
@@ -871,7 +871,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
871 871
 
872 872
                 //opposite parity is always in the same frame if this is second field
873 873
                 if(!s->first_field){
874
-                    ref_picture = s->current_picture_ptr->data;
874
+                    ref_picture = s->current_picture_ptr->f.data;
875 875
                 }
876 876
             }
877 877
         }
... ...
@@ -158,7 +158,7 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix){
158 158
  * init s->current_picture.qscale_table from s->lambda_table
159 159
  */
160 160
 void ff_init_qscale_tab(MpegEncContext *s){
161
-    int8_t * const qscale_table= s->current_picture.qscale_table;
161
+    int8_t * const qscale_table = s->current_picture.f.qscale_table;
162 162
     int i;
163 163
 
164 164
     for(i=0; i<s->mb_num; i++){
... ...
@@ -915,12 +915,12 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){
915 915
     int64_t score64=0;
916 916
 
917 917
     for(plane=0; plane<3; plane++){
918
-        const int stride= p->linesize[plane];
918
+        const int stride = p->f.linesize[plane];
919 919
         const int bw= plane ? 1 : 2;
920 920
         for(y=0; y<s->mb_height*bw; y++){
921 921
             for(x=0; x<s->mb_width*bw; x++){
922
-                int off= p->type == FF_BUFFER_TYPE_SHARED ? 0: 16;
923
-                int v= s->dsp.frame_skip_cmp[1](s, p->data[plane] + 8*(x + y*stride)+off, ref->data[plane] + 8*(x + y*stride), stride, 8);
922
+                int off = p->f.type == FF_BUFFER_TYPE_SHARED ? 0: 16;
923
+                int v   = s->dsp.frame_skip_cmp[1](s, p->f.data[plane] + 8*(x + y*stride)+off, ref->f.data[plane] + 8*(x + y*stride), stride, 8);
924 924
 
925 925
                 switch(s->avctx->frame_skip_exp){
926 926
                     case 0: score= FFMAX(score, v); break;
... ...
@@ -992,15 +992,15 @@ static int estimate_best_b_count(MpegEncContext *s){
992 992
         if(pre_input_ptr && (!i || s->input_picture[i-1])) {
993 993
             pre_input= *pre_input_ptr;
994 994
 
995
-            if(pre_input.type != FF_BUFFER_TYPE_SHARED && i) {
996
-                pre_input.data[0]+=INPLACE_OFFSET;
997
-                pre_input.data[1]+=INPLACE_OFFSET;
998
-                pre_input.data[2]+=INPLACE_OFFSET;
995
+            if (pre_input.f.type != FF_BUFFER_TYPE_SHARED && i) {
996
+                pre_input.f.data[0] += INPLACE_OFFSET;
997
+                pre_input.f.data[1] += INPLACE_OFFSET;
998
+                pre_input.f.data[2] += INPLACE_OFFSET;
999 999
             }
1000 1000
 
1001
-            s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.data[0], pre_input.linesize[0], c->width, c->height);
1002
-            s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.data[1], pre_input.linesize[1], c->width>>1, c->height>>1);
1003
-            s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.data[2], pre_input.linesize[2], c->width>>1, c->height>>1);
1001
+            s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.f.data[0], pre_input.f.linesize[0], c->width,      c->height);
1002
+            s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.f.data[1], pre_input.f.linesize[1], c->width >> 1, c->height >> 1);
1003
+            s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.f.data[2], pre_input.f.linesize[2], c->width >> 1, c->height >> 1);
1004 1004
         }
1005 1005
     }
1006 1006
 
... ...
@@ -1062,20 +1062,20 @@ static int select_input_picture(MpegEncContext *s){
1062 1062
     if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
1063 1063
         if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
1064 1064
             s->reordered_input_picture[0]= s->input_picture[0];
1065
-            s->reordered_input_picture[0]->pict_type= AV_PICTURE_TYPE_I;
1066
-            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
1065
+            s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_I;
1066
+            s->reordered_input_picture[0]->f.coded_picture_number = s->coded_picture_number++;
1067 1067
         }else{
1068 1068
             int b_frames;
1069 1069
 
1070 1070
             if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){
1071 1071
                 if(s->picture_in_gop_number < s->gop_size && skip_check(s, s->input_picture[0], s->next_picture_ptr)){
1072 1072
                 //FIXME check that te gop check above is +-1 correct
1073
-//av_log(NULL, AV_LOG_DEBUG, "skip %p %"PRId64"\n", s->input_picture[0]->data[0], s->input_picture[0]->pts);
1073
+//av_log(NULL, AV_LOG_DEBUG, "skip %p %"PRId64"\n", s->input_picture[0]->f.data[0], s->input_picture[0]->pts);
1074 1074
 
1075
-                    if(s->input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
1075
+                    if (s->input_picture[0]->f.type == FF_BUFFER_TYPE_SHARED) {
1076 1076
                         for(i=0; i<4; i++)
1077
-                            s->input_picture[0]->data[i]= NULL;
1078
-                        s->input_picture[0]->type= 0;
1077
+                            s->input_picture[0]->f.data[i] = NULL;
1078
+                        s->input_picture[0]->f.type = 0;
1079 1079
                     }else{
1080 1080
                         assert(   s->input_picture[0]->type==FF_BUFFER_TYPE_USER
1081 1081
                                || s->input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
... ...
@@ -1092,7 +1092,7 @@ static int select_input_picture(MpegEncContext *s){
1092 1092
 
1093 1093
             if(s->flags&CODEC_FLAG_PASS2){
1094 1094
                 for(i=0; i<s->max_b_frames+1; i++){
1095
-                    int pict_num= s->input_picture[0]->display_picture_number + i;
1095
+                    int pict_num = s->input_picture[0]->f.display_picture_number + i;
1096 1096
 
1097 1097
                     if(pict_num >= s->rc_context.num_entries)
1098 1098
                         break;
... ...
@@ -1101,7 +1101,7 @@ static int select_input_picture(MpegEncContext *s){
1101 1101
                         break;
1102 1102
                     }
1103 1103
 
1104
-                    s->input_picture[i]->pict_type=
1104
+                    s->input_picture[i]->f.pict_type =
1105 1105
                         s->rc_context.entry[pict_num].new_pict_type;
1106 1106
                 }
1107 1107
             }
... ...
@@ -1113,8 +1113,8 @@ static int select_input_picture(MpegEncContext *s){
1113 1113
                 for(i=1; i<s->max_b_frames+1; i++){
1114 1114
                     if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){
1115 1115
                         s->input_picture[i]->b_frame_score=
1116
-                            get_intra_count(s, s->input_picture[i  ]->data[0],
1117
-                                               s->input_picture[i-1]->data[0], s->linesize) + 1;
1116
+                            get_intra_count(s, s->input_picture[i  ]->f.data[0],
1117
+                                               s->input_picture[i-1]->f.data[0], s->linesize) + 1;
1118 1118
                     }
1119 1119
                 }
1120 1120
                 for(i=0; i<s->max_b_frames+1; i++){
... ...
@@ -1140,11 +1140,11 @@ static int select_input_picture(MpegEncContext *s){
1140 1140
 //av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count);
1141 1141
 
1142 1142
             for(i= b_frames - 1; i>=0; i--){
1143
-                int type= s->input_picture[i]->pict_type;
1143
+                int type = s->input_picture[i]->f.pict_type;
1144 1144
                 if(type && type != AV_PICTURE_TYPE_B)
1145 1145
                     b_frames= i;
1146 1146
             }
1147
-            if(s->input_picture[b_frames]->pict_type == AV_PICTURE_TYPE_B && b_frames == s->max_b_frames){
1147
+            if (s->input_picture[b_frames]->f.pict_type == AV_PICTURE_TYPE_B && b_frames == s->max_b_frames){
1148 1148
                 av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n");
1149 1149
             }
1150 1150
 
... ...
@@ -1154,49 +1154,49 @@ static int select_input_picture(MpegEncContext *s){
1154 1154
               }else{
1155 1155
                 if(s->flags & CODEC_FLAG_CLOSED_GOP)
1156 1156
                     b_frames=0;
1157
-                s->input_picture[b_frames]->pict_type= AV_PICTURE_TYPE_I;
1157
+                s->input_picture[b_frames]->f.pict_type = AV_PICTURE_TYPE_I;
1158 1158
               }
1159 1159
             }
1160 1160
 
1161 1161
             if(   (s->flags & CODEC_FLAG_CLOSED_GOP)
1162 1162
                && b_frames
1163
-               && s->input_picture[b_frames]->pict_type== AV_PICTURE_TYPE_I)
1163
+               && s->input_picture[b_frames]->f.pict_type== AV_PICTURE_TYPE_I)
1164 1164
                 b_frames--;
1165 1165
 
1166 1166
             s->reordered_input_picture[0]= s->input_picture[b_frames];
1167
-            if(s->reordered_input_picture[0]->pict_type != AV_PICTURE_TYPE_I)
1168
-                s->reordered_input_picture[0]->pict_type= AV_PICTURE_TYPE_P;
1169
-            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
1167
+            if (s->reordered_input_picture[0]->f.pict_type != AV_PICTURE_TYPE_I)
1168
+                s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_P;
1169
+            s->reordered_input_picture[0]->f.coded_picture_number = s->coded_picture_number++;
1170 1170
             for(i=0; i<b_frames; i++){
1171
-                s->reordered_input_picture[i+1]= s->input_picture[i];
1172
-                s->reordered_input_picture[i+1]->pict_type= AV_PICTURE_TYPE_B;
1173
-                s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++;
1171
+                s->reordered_input_picture[i + 1] = s->input_picture[i];
1172
+                s->reordered_input_picture[i + 1]->f.pict_type = AV_PICTURE_TYPE_B;
1173
+                s->reordered_input_picture[i + 1]->f.coded_picture_number = s->coded_picture_number++;
1174 1174
             }
1175 1175
         }
1176 1176
     }
1177 1177
 no_output_pic:
1178 1178
     if(s->reordered_input_picture[0]){
1179
-        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=AV_PICTURE_TYPE_B ? 3 : 0;
1179
+        s->reordered_input_picture[0]->f.reference = s->reordered_input_picture[0]->f.pict_type!=AV_PICTURE_TYPE_B ? 3 : 0;
1180 1180
 
1181 1181
         ff_copy_picture(&s->new_picture, s->reordered_input_picture[0]);
1182 1182
 
1183
-        if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size){
1183
+        if (s->reordered_input_picture[0]->f.type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size) {
1184 1184
             // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable
1185 1185
 
1186 1186
             int i= ff_find_unused_picture(s, 0);
1187 1187
             Picture *pic= &s->picture[i];
1188 1188
 
1189
-            pic->reference              = s->reordered_input_picture[0]->reference;
1189
+            pic->f.reference = s->reordered_input_picture[0]->f.reference;
1190 1190
             if(ff_alloc_picture(s, pic, 0) < 0){
1191 1191
                 return -1;
1192 1192
             }
1193 1193
 
1194 1194
             /* mark us unused / free shared pic */
1195
-            if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_INTERNAL)
1195
+            if (s->reordered_input_picture[0]->f.type == FF_BUFFER_TYPE_INTERNAL)
1196 1196
                 s->avctx->release_buffer(s->avctx, (AVFrame*)s->reordered_input_picture[0]);
1197 1197
             for(i=0; i<4; i++)
1198
-                s->reordered_input_picture[0]->data[i]= NULL;
1199
-            s->reordered_input_picture[0]->type= 0;
1198
+                s->reordered_input_picture[0]->f.data[i] = NULL;
1199
+            s->reordered_input_picture[0]->f.type = 0;
1200 1200
 
1201 1201
             copy_picture_attributes(s, (AVFrame*)pic, (AVFrame*)s->reordered_input_picture[0]);
1202 1202
 
... ...
@@ -1209,12 +1209,12 @@ no_output_pic:
1209 1209
 
1210 1210
             s->current_picture_ptr= s->reordered_input_picture[0];
1211 1211
             for(i=0; i<4; i++){
1212
-                s->new_picture.data[i]+= INPLACE_OFFSET;
1212
+                s->new_picture.f.data[i] += INPLACE_OFFSET;
1213 1213
             }
1214 1214
         }
1215 1215
         ff_copy_picture(&s->current_picture, s->current_picture_ptr);
1216 1216
 
1217
-        s->picture_number= s->new_picture.display_picture_number;
1217
+        s->picture_number = s->new_picture.f.display_picture_number;
1218 1218
 //printf("dpn:%d\n", s->picture_number);
1219 1219
     }else{
1220 1220
        memset(&s->new_picture, 0, sizeof(Picture));
... ...
@@ -1249,8 +1249,8 @@ int MPV_encode_picture(AVCodecContext *avctx,
1249 1249
     }
1250 1250
 
1251 1251
     /* output? */
1252
-    if(s->new_picture.data[0]){
1253
-        s->pict_type= s->new_picture.pict_type;
1252
+    if (s->new_picture.f.data[0]) {
1253
+        s->pict_type = s->new_picture.f.pict_type;
1254 1254
 //emms_c();
1255 1255
 //printf("qs:%f %f %d\n", s->new_picture.quality, s->current_picture.quality, s->qscale);
1256 1256
         MPV_frame_start(s, avctx);
... ...
@@ -1307,8 +1307,8 @@ vbv_retry:
1307 1307
             ff_write_pass1_stats(s);
1308 1308
 
1309 1309
         for(i=0; i<4; i++){
1310
-            s->current_picture_ptr->error[i]= s->current_picture.error[i];
1311
-            avctx->error[i] += s->current_picture_ptr->error[i];
1310
+            s->current_picture_ptr->f.error[i]  = s->current_picture.f.error[i];
1311
+            avctx->error[i]                        += s->current_picture_ptr->f.error[i];
1312 1312
         }
1313 1313
 
1314 1314
         if(s->flags&CODEC_FLAG_PASS1)
... ...
@@ -1508,7 +1508,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
1508 1508
         update_qscale(s);
1509 1509
 
1510 1510
         if(!(s->flags&CODEC_FLAG_QP_RD)){
1511
-            s->qscale= s->current_picture_ptr->qscale_table[mb_xy];
1511
+            s->qscale = s->current_picture_ptr->f.qscale_table[mb_xy];
1512 1512
             s->dquant= s->qscale - last_qp;
1513 1513
 
1514 1514
             if(s->out_format==FMT_H263){
... ...
@@ -1532,9 +1532,9 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
1532 1532
 
1533 1533
     wrap_y = s->linesize;
1534 1534
     wrap_c = s->uvlinesize;
1535
-    ptr_y = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
1536
-    ptr_cb = s->new_picture.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
1537
-    ptr_cr = s->new_picture.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
1535
+    ptr_y  = s->new_picture.f.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
1536
+    ptr_cb = s->new_picture.f.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
1537
+    ptr_cr = s->new_picture.f.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
1538 1538
 
1539 1539
     if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
1540 1540
         uint8_t *ebuf= s->edge_emu_buffer + 32;
... ...
@@ -1602,12 +1602,12 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
1602 1602
         }
1603 1603
 
1604 1604
         if (s->mv_dir & MV_DIR_FORWARD) {
1605
-            MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
1605
+            MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix);
1606 1606
             op_pix = s->dsp.avg_pixels_tab;
1607 1607
             op_qpix= s->dsp.avg_qpel_pixels_tab;
1608 1608
         }
1609 1609
         if (s->mv_dir & MV_DIR_BACKWARD) {
1610
-            MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
1610
+            MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix);
1611 1611
         }
1612 1612
 
1613 1613
         if(s->flags&CODEC_FLAG_INTERLACED_DCT){
... ...
@@ -1933,18 +1933,18 @@ static int sse_mb(MpegEncContext *s){
1933 1933
 
1934 1934
     if(w==16 && h==16)
1935 1935
       if(s->avctx->mb_cmp == FF_CMP_NSSE){
1936
-        return  s->dsp.nsse[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
1937
-               +s->dsp.nsse[1](s, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
1938
-               +s->dsp.nsse[1](s, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
1936
+        return  s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
1937
+               +s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
1938
+               +s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
1939 1939
       }else{
1940
-        return  s->dsp.sse[0](NULL, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
1941
-               +s->dsp.sse[1](NULL, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
1942
-               +s->dsp.sse[1](NULL, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
1940
+        return  s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
1941
+               +s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
1942
+               +s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
1943 1943
       }
1944 1944
     else
1945
-        return  sse(s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
1946
-               +sse(s, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
1947
-               +sse(s, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
1945
+        return  sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
1946
+               +sse(s, s->new_picture.f.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
1947
+               +sse(s, s->new_picture.f.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
1948 1948
 }
1949 1949
 
1950 1950
 static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
... ...
@@ -2003,7 +2003,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
2003 2003
         for(mb_x=0; mb_x < s->mb_width; mb_x++) {
2004 2004
             int xx = mb_x * 16;
2005 2005
             int yy = mb_y * 16;
2006
-            uint8_t *pix = s->new_picture.data[0] + (yy * s->linesize) + xx;
2006
+            uint8_t *pix = s->new_picture.f.data[0] + (yy * s->linesize) + xx;
2007 2007
             int varc;
2008 2008
             int sum = s->dsp.pix_sum(pix, s->linesize);
2009 2009
 
... ...
@@ -2070,7 +2070,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
2070 2070
         /* note: quant matrix value (8) is implied here */
2071 2071
         s->last_dc[i] = 128 << s->intra_dc_precision;
2072 2072
 
2073
-        s->current_picture.error[i] = 0;
2073
+        s->current_picture.f.error[i] = 0;
2074 2074
     }
2075 2075
     s->mb_skip_run = 0;
2076 2076
     memset(s->last_mv, 0, sizeof(s->last_mv));
... ...
@@ -2271,8 +2271,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
2271 2271
                     s->mv_type = MV_TYPE_8X8;
2272 2272
                     s->mb_intra= 0;
2273 2273
                     for(i=0; i<4; i++){
2274
-                        s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
2275
-                        s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
2274
+                        s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0];
2275
+                        s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1];
2276 2276
                     }
2277 2277
                     encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
2278 2278
                                  &dmin, &next_block, 0, 0);
... ...
@@ -2458,7 +2458,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
2458 2458
                     }
2459 2459
                 }
2460 2460
 
2461
-                s->current_picture.qscale_table[xy]= best_s.qscale;
2461
+                s->current_picture.f.qscale_table[xy] = best_s.qscale;
2462 2462
 
2463 2463
                 copy_context_after_encode(s, &best_s, -1);
2464 2464
 
... ...
@@ -2525,8 +2525,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
2525 2525
                     s->mv_type = MV_TYPE_8X8;
2526 2526
                     s->mb_intra= 0;
2527 2527
                     for(i=0; i<4; i++){
2528
-                        s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
2529
-                        s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
2528
+                        s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0];
2529
+                        s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1];
2530 2530
                     }
2531 2531
                     break;
2532 2532
                 case CANDIDATE_MB_TYPE_DIRECT:
... ...
@@ -2627,14 +2627,14 @@ static int encode_thread(AVCodecContext *c, void *arg){
2627 2627
                 if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
2628 2628
                 if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
2629 2629
 
2630
-                s->current_picture.error[0] += sse(
2631
-                    s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
2630
+                s->current_picture.f.error[0] += sse(
2631
+                    s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
2632 2632
                     s->dest[0], w, h, s->linesize);
2633
-                s->current_picture.error[1] += sse(
2634
-                    s, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*chr_h,
2633
+                s->current_picture.f.error[1] += sse(
2634
+                    s, s->new_picture.f.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*chr_h,
2635 2635
                     s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
2636
-                s->current_picture.error[2] += sse(
2637
-                    s, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*chr_h,
2636
+                s->current_picture.f.error[2] += sse(
2637
+                    s, s->new_picture.f.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*chr_h,
2638 2638
                     s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
2639 2639
             }
2640 2640
             if(s->loop_filter){
... ...
@@ -2685,9 +2685,9 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
2685 2685
     MERGE(misc_bits);
2686 2686
     MERGE(error_count);
2687 2687
     MERGE(padding_bug_score);
2688
-    MERGE(current_picture.error[0]);
2689
-    MERGE(current_picture.error[1]);
2690
-    MERGE(current_picture.error[2]);
2688
+    MERGE(current_picture.f.error[0]);
2689
+    MERGE(current_picture.f.error[1]);
2690
+    MERGE(current_picture.f.error[2]);
2691 2691
 
2692 2692
     if(dst->avctx->noise_reduction){
2693 2693
         for(i=0; i<64; i++){
... ...
@@ -2704,13 +2704,13 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
2704 2704
 
2705 2705
 static int estimate_qp(MpegEncContext *s, int dry_run){
2706 2706
     if (s->next_lambda){
2707
-        s->current_picture_ptr->quality=
2708
-        s->current_picture.quality = s->next_lambda;
2707
+        s->current_picture_ptr->f.quality =
2708
+        s->current_picture.f.quality = s->next_lambda;
2709 2709
         if(!dry_run) s->next_lambda= 0;
2710 2710
     } else if (!s->fixed_qscale) {
2711
-        s->current_picture_ptr->quality=
2712
-        s->current_picture.quality = ff_rate_estimate_qscale(s, dry_run);
2713
-        if (s->current_picture.quality < 0)
2711
+        s->current_picture_ptr->f.quality =
2712
+        s->current_picture.f.quality = ff_rate_estimate_qscale(s, dry_run);
2713
+        if (s->current_picture.f.quality < 0)
2714 2714
             return -1;
2715 2715
     }
2716 2716
 
... ...
@@ -2733,7 +2733,7 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
2733 2733
         s->lambda= s->lambda_table[0];
2734 2734
         //FIXME broken
2735 2735
     }else
2736
-        s->lambda= s->current_picture.quality;
2736
+        s->lambda = s->current_picture.f.quality;
2737 2737
 //printf("%d %d\n", s->avctx->global_quality, s->current_picture.quality);
2738 2738
     update_qscale(s);
2739 2739
     return 0;
... ...
@@ -2742,7 +2742,7 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
2742 2742
 /* must be called before writing the header */
2743 2743
 static void set_frame_distances(MpegEncContext * s){
2744 2744
     assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
2745
-    s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
2745
+    s->time = s->current_picture_ptr->f.pts * s->avctx->time_base.num;
2746 2746
 
2747 2747
     if(s->pict_type==AV_PICTURE_TYPE_B){
2748 2748
         s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
... ...
@@ -2916,12 +2916,12 @@ static int encode_picture(MpegEncContext *s, int picture_number)
2916 2916
     }
2917 2917
 
2918 2918
     //FIXME var duplication
2919
-    s->current_picture_ptr->key_frame=
2920
-    s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr
2921
-    s->current_picture_ptr->pict_type=
2922
-    s->current_picture.pict_type= s->pict_type;
2919
+    s->current_picture_ptr->f.key_frame =
2920
+    s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr
2921
+    s->current_picture_ptr->f.pict_type =
2922
+    s->current_picture.f.pict_type = s->pict_type;
2923 2923
 
2924
-    if(s->current_picture.key_frame)
2924
+    if (s->current_picture.f.key_frame)
2925 2925
         s->picture_in_gop_number=0;
2926 2926
 
2927 2927
     s->last_bits= put_bits_count(&s->pb);
... ...
@@ -41,7 +41,7 @@
41 41
  */
42 42
 void ff_xvmc_init_block(MpegEncContext *s)
43 43
 {
44
-    struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.data[2];
44
+    struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
45 45
     assert(render && render->xvmc_id == AV_XVMC_ID);
46 46
 
47 47
     s->block = (DCTELEM (*)[64])(render->data_blocks + render->next_free_data_block_num * 64);
... ...
@@ -73,7 +73,7 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
73 73
  */
74 74
 int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
75 75
 {
76
-    struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.data[2];
76
+    struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
77 77
     const int mb_block_count = 4 + (1 << s->chroma_format);
78 78
 
79 79
     assert(avctx);
... ...
@@ -113,7 +113,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
113 113
         case  AV_PICTURE_TYPE_I:
114 114
             return 0; // no prediction from other frames
115 115
         case  AV_PICTURE_TYPE_B:
116
-            next = (struct xvmc_pix_fmt*)s->next_picture.data[2];
116
+            next = (struct xvmc_pix_fmt*)s->next_picture.f.data[2];
117 117
             if (!next)
118 118
                 return -1;
119 119
             if (next->xvmc_id != AV_XVMC_ID)
... ...
@@ -121,7 +121,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
121 121
             render->p_future_surface = next->p_surface;
122 122
             // no return here, going to set forward prediction
123 123
         case  AV_PICTURE_TYPE_P:
124
-            last = (struct xvmc_pix_fmt*)s->last_picture.data[2];
124
+            last = (struct xvmc_pix_fmt*)s->last_picture.f.data[2];
125 125
             if (!last)
126 126
                 last = render; // predict second field from the first
127 127
             if (last->xvmc_id != AV_XVMC_ID)
... ...
@@ -141,7 +141,7 @@ return -1;
141 141
  */
142 142
 void ff_xvmc_field_end(MpegEncContext *s)
143 143
 {
144
-    struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.data[2];
144
+    struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
145 145
     assert(render);
146 146
 
147 147
     if (render->filled_mv_blocks_num > 0)
... ...
@@ -179,10 +179,10 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
179 179
 
180 180
     // Do I need to export quant when I could not perform postprocessing?
181 181
     // Anyway, it doesn't hurt.
182
-    s->current_picture.qscale_table[mb_xy] = s->qscale;
182
+    s->current_picture.f.qscale_table[mb_xy] = s->qscale;
183 183
 
184 184
     // start of XVMC-specific code
185
-    render = (struct xvmc_pix_fmt*)s->current_picture.data[2];
185
+    render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
186 186
     assert(render);
187 187
     assert(render->xvmc_id == AV_XVMC_ID);
188 188
     assert(render->mv_blocks);
... ...
@@ -780,10 +780,10 @@ static inline int msmpeg4_pred_dc(MpegEncContext * s, int n,
780 780
             }else{
781 781
                 if(n<4){
782 782
                     wrap= s->linesize;
783
-                    dest= s->current_picture.data[0] + (((n>>1) + 2*s->mb_y) * 8*  wrap ) + ((n&1) + 2*s->mb_x) * 8;
783
+                    dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8*  wrap ) + ((n & 1) + 2*s->mb_x) * 8;
784 784
                 }else{
785 785
                     wrap= s->uvlinesize;
786
-                    dest= s->current_picture.data[n-3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
786
+                    dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
787 787
                 }
788 788
                 if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
789 789
                 else           a= get_dc(dest-8, wrap, scale*8);
... ...
@@ -1172,7 +1172,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
1172 1172
 {
1173 1173
     int cbp, code, i;
1174 1174
     uint8_t *coded_val;
1175
-    uint32_t * const mb_type_ptr= &s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ];
1175
+    uint32_t * const mb_type_ptr = &s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride];
1176 1176
 
1177 1177
     if (s->pict_type == AV_PICTURE_TYPE_P) {
1178 1178
         if (s->use_skip_mb_code) {
... ...
@@ -408,9 +408,10 @@ static void release_delayed_buffers(PerThreadContext *p)
408 408
     FrameThreadContext *fctx = p->parent;
409 409
 
410 410
     while (p->num_released_buffers > 0) {
411
-        AVFrame *f = &p->released_buffers[--p->num_released_buffers];
411
+        AVFrame *f;
412 412
 
413 413
         pthread_mutex_lock(&fctx->buffer_mutex);
414
+        f = &p->released_buffers[--p->num_released_buffers];
414 415
         free_progress(f);
415 416
         f->thread_opaque = NULL;
416 417
 
... ...
@@ -746,9 +747,12 @@ void ff_thread_flush(AVCodecContext *avctx)
746 746
     if (!avctx->thread_opaque) return;
747 747
 
748 748
     park_frame_worker_threads(fctx, avctx->thread_count);
749
-
750
-    if (fctx->prev_thread)
751
-        update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);
749
+    if (fctx->prev_thread) {
750
+        if (fctx->prev_thread != &fctx->threads[0])
751
+            update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
752
+        if (avctx->codec->flush)
753
+            avctx->codec->flush(fctx->threads[0].avctx);
754
+    }
752 755
 
753 756
     fctx->next_decoding = fctx->next_finished = 0;
754 757
     fctx->delaying = 1;
... ...
@@ -836,6 +840,7 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
836 836
 void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
837 837
 {
838 838
     PerThreadContext *p = avctx->thread_opaque;
839
+    FrameThreadContext *fctx;
839 840
 
840 841
     if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
841 842
         avctx->release_buffer(avctx, f);
... ...
@@ -851,7 +856,10 @@ void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
851 851
         av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p, %d buffers used\n",
852 852
                                     f, f->owner->internal_buffer_count);
853 853
 
854
+    fctx = p->parent;
855
+    pthread_mutex_lock(&fctx->buffer_mutex);
854 856
     p->released_buffers[p->num_released_buffers++] = *f;
857
+    pthread_mutex_unlock(&fctx->buffer_mutex);
855 858
     memset(f->data, 0, sizeof(f->data));
856 859
 }
857 860
 
... ...
@@ -44,9 +44,9 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f
44 44
 
45 45
 void ff_write_pass1_stats(MpegEncContext *s){
46 46
     snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n",
47
-            s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type,
48
-            s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits,
49
-            s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, s->header_bits);
47
+             s->current_picture_ptr->f.display_picture_number, s->current_picture_ptr->f.coded_picture_number, s->pict_type,
48
+             s->current_picture.f.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits,
49
+             s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, s->header_bits);
50 50
 }
51 51
 
52 52
 static inline double qp2bits(RateControlEntry *rce, double qp){
... ...
@@ -707,10 +707,10 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
707 707
 //if(dts_pic)
708 708
 //            av_log(NULL, AV_LOG_ERROR, "%Ld %Ld %Ld %d\n", s->current_picture_ptr->pts, s->user_specified_pts, dts_pic->pts, picture_number);
709 709
 
710
-        if(!dts_pic || dts_pic->pts == AV_NOPTS_VALUE)
710
+        if (!dts_pic || dts_pic->f.pts == AV_NOPTS_VALUE)
711 711
             wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);
712 712
         else
713
-            wanted_bits= (uint64_t)(s->bit_rate*(double)dts_pic->pts/fps);
713
+            wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps);
714 714
     }
715 715
 
716 716
     diff= s->total_bits - wanted_bits;
... ...
@@ -142,7 +142,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
142 142
 
143 143
     mb_pos = row * s->mb_stride;
144 144
     for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
145
-        int mbtype = s->current_picture_ptr->mb_type[mb_pos];
145
+        int mbtype = s->current_picture_ptr->f.mb_type[mb_pos];
146 146
         if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype))
147 147
             r->deblock_coefs[mb_pos] = 0xFFFF;
148 148
         if(IS_INTRA(mbtype))
... ...
@@ -154,11 +154,11 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
154 154
      */
155 155
     mb_pos = row * s->mb_stride;
156 156
     for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
157
-        cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]];
157
+        cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos]];
158 158
         if(mb_x)
159
-            left_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - 1]];
159
+            left_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos - 1]];
160 160
         for(j = 0; j < 16; j += 4){
161
-            Y = s->current_picture_ptr->data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x;
161
+            Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x;
162 162
             for(i = !mb_x; i < 4; i++, Y += 4){
163 163
                 int ij = i + j;
164 164
                 loc_lim = 0;
... ...
@@ -178,7 +178,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
178 178
             if(mb_x)
179 179
                 left_cbp = (r->cbp_chroma[mb_pos - 1] >> (k*4)) & 0xF;
180 180
             for(j = 0; j < 8; j += 4){
181
-                C = s->current_picture_ptr->data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x;
181
+                C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x;
182 182
                 for(i = !mb_x; i < 2; i++, C += 4){
183 183
                     int ij = i + (j >> 1);
184 184
                     loc_lim = 0;
... ...
@@ -196,11 +196,11 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
196 196
     }
197 197
     mb_pos = row * s->mb_stride;
198 198
     for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
199
-        cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]];
199
+        cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos]];
200 200
         if(row)
201
-            top_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - s->mb_stride]];
201
+            top_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos - s->mb_stride]];
202 202
         for(j = 4*!row; j < 16; j += 4){
203
-            Y = s->current_picture_ptr->data[0] + mb_x*16 + (row*16 + j) * s->linesize;
203
+            Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize;
204 204
             for(i = 0; i < 4; i++, Y += 4){
205 205
                 int ij = i + j;
206 206
                 loc_lim = 0;
... ...
@@ -220,7 +220,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
220 220
             if(row)
221 221
                 top_cbp = (r->cbp_chroma[mb_pos - s->mb_stride] >> (k*4)) & 0xF;
222 222
             for(j = 4*!row; j < 8; j += 4){
223
-                C = s->current_picture_ptr->data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize;
223
+                C = s->current_picture_ptr->f.data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize;
224 224
                 for(i = 0; i < 2; i++, C += 4){
225 225
                     int ij = i + (j >> 1);
226 226
                     loc_lim = 0;
... ...
@@ -439,13 +439,13 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types)
439 439
             if(!get_bits1(gb))
440 440
                 av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n");
441 441
         }
442
-        s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA;
442
+        s->current_picture_ptr->f.mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA;
443 443
         r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA;
444 444
     }else{
445 445
         r->block_type = r->decode_mb_info(r);
446 446
         if(r->block_type == -1)
447 447
             return -1;
448
-        s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type];
448
+        s->current_picture_ptr->f.mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type];
449 449
         r->mb_type[mb_pos] = r->block_type;
450 450
         if(r->block_type == RV34_MB_SKIP){
451 451
             if(s->pict_type == AV_PICTURE_TYPE_P)
... ...
@@ -453,7 +453,7 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types)
453 453
             if(s->pict_type == AV_PICTURE_TYPE_B)
454 454
                 r->mb_type[mb_pos] = RV34_MB_B_DIRECT;
455 455
         }
456
-        r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]);
456
+        r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->f.mb_type[mb_pos]);
457 457
         rv34_decode_mv(r, r->block_type);
458 458
         if(r->block_type == RV34_MB_SKIP){
459 459
             fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0]));
... ...
@@ -462,7 +462,7 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types)
462 462
         r->chroma_vlc = 1;
463 463
         r->luma_vlc   = 0;
464 464
     }
465
-    if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){
465
+    if(IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])){
466 466
         if(r->is16){
467 467
             t = get_bits(gb, 2);
468 468
             fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0]));
... ...
@@ -527,27 +527,27 @@ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int
527 527
         c_off = -1;
528 528
 
529 529
     if(r->avail_cache[avail_index - 1]){
530
-        A[0] = s->current_picture_ptr->motion_val[0][mv_pos-1][0];
531
-        A[1] = s->current_picture_ptr->motion_val[0][mv_pos-1][1];
530
+        A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][0];
531
+        A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][1];
532 532
     }
533 533
     if(r->avail_cache[avail_index - 4]){
534
-        B[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][0];
535
-        B[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][1];
534
+        B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][0];
535
+        B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][1];
536 536
     }else{
537 537
         B[0] = A[0];
538 538
         B[1] = A[1];
539 539
     }
540 540
     if(!r->avail_cache[avail_index - 4 + c_off]){
541 541
         if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1] || r->rv30)){
542
-            C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][0];
543
-            C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][1];
542
+            C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][0];
543
+            C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][1];
544 544
         }else{
545 545
             C[0] = A[0];
546 546
             C[1] = A[1];
547 547
         }
548 548
     }else{
549
-        C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+c_off][0];
550
-        C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+c_off][1];
549
+        C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][0];
550
+        C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][1];
551 551
     }
552 552
     mx = mid_pred(A[0], B[0], C[0]);
553 553
     my = mid_pred(A[1], B[1], C[1]);
... ...
@@ -555,8 +555,8 @@ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int
555 555
     my += r->dmv[dmv_no][1];
556 556
     for(j = 0; j < part_sizes_h[block_type]; j++){
557 557
         for(i = 0; i < part_sizes_w[block_type]; i++){
558
-            s->current_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx;
559
-            s->current_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][1] = my;
558
+            s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx;
559
+            s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][1] = my;
560 560
         }
561 561
     }
562 562
 }
... ...
@@ -611,28 +611,28 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir)
611 611
     int i, j;
612 612
     Picture *cur_pic = s->current_picture_ptr;
613 613
     const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0;
614
-    int type = cur_pic->mb_type[mb_pos];
614
+    int type = cur_pic->f.mb_type[mb_pos];
615 615
 
616 616
     memset(A, 0, sizeof(A));
617 617
     memset(B, 0, sizeof(B));
618 618
     memset(C, 0, sizeof(C));
619 619
     if((r->avail_cache[6-1] & type) & mask){
620
-        A[0] = cur_pic->motion_val[dir][mv_pos - 1][0];
621
-        A[1] = cur_pic->motion_val[dir][mv_pos - 1][1];
620
+        A[0] = cur_pic->f.motion_val[dir][mv_pos - 1][0];
621
+        A[1] = cur_pic->f.motion_val[dir][mv_pos - 1][1];
622 622
         has_A = 1;
623 623
     }
624 624
     if((r->avail_cache[6-4] & type) & mask){
625
-        B[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][0];
626
-        B[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][1];
625
+        B[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride][0];
626
+        B[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride][1];
627 627
         has_B = 1;
628 628
     }
629 629
     if(r->avail_cache[6-4] && (r->avail_cache[6-2] & type) & mask){
630
-        C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][0];
631
-        C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][1];
630
+        C[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride + 2][0];
631
+        C[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride + 2][1];
632 632
         has_C = 1;
633 633
     }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[6-5] & type) & mask){
634
-        C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][0];
635
-        C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][1];
634
+        C[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride - 1][0];
635
+        C[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride - 1][1];
636 636
         has_C = 1;
637 637
     }
638 638
 
... ...
@@ -643,12 +643,12 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir)
643 643
 
644 644
     for(j = 0; j < 2; j++){
645 645
         for(i = 0; i < 2; i++){
646
-            cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx;
647
-            cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my;
646
+            cur_pic->f.motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx;
647
+            cur_pic->f.motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my;
648 648
         }
649 649
     }
650 650
     if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD){
651
-        ZERO8x2(cur_pic->motion_val[!dir][mv_pos], s->b8_stride);
651
+        ZERO8x2(cur_pic->f.motion_val[!dir][mv_pos], s->b8_stride);
652 652
     }
653 653
 }
654 654
 
... ...
@@ -665,27 +665,27 @@ static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir)
665 665
     int avail_index = avail_indexes[0];
666 666
 
667 667
     if(r->avail_cache[avail_index - 1]){
668
-        A[0] = s->current_picture_ptr->motion_val[0][mv_pos-1][0];
669
-        A[1] = s->current_picture_ptr->motion_val[0][mv_pos-1][1];
668
+        A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - 1][0];
669
+        A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - 1][1];
670 670
     }
671 671
     if(r->avail_cache[avail_index - 4]){
672
-        B[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][0];
673
-        B[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][1];
672
+        B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride][0];
673
+        B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride][1];
674 674
     }else{
675 675
         B[0] = A[0];
676 676
         B[1] = A[1];
677 677
     }
678 678
     if(!r->avail_cache[avail_index - 4 + 2]){
679 679
         if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1])){
680
-            C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][0];
681
-            C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][1];
680
+            C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride - 1][0];
681
+            C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride - 1][1];
682 682
         }else{
683 683
             C[0] = A[0];
684 684
             C[1] = A[1];
685 685
         }
686 686
     }else{
687
-        C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+2][0];
688
-        C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+2][1];
687
+        C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride + 2][0];
688
+        C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride + 2][1];
689 689
     }
690 690
     mx = mid_pred(A[0], B[0], C[0]);
691 691
     my = mid_pred(A[1], B[1], C[1]);
... ...
@@ -694,8 +694,8 @@ static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir)
694 694
     for(j = 0; j < 2; j++){
695 695
         for(i = 0; i < 2; i++){
696 696
             for(k = 0; k < 2; k++){
697
-                s->current_picture_ptr->motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx;
698
-                s->current_picture_ptr->motion_val[k][mv_pos + i + j*s->b8_stride][1] = my;
697
+                s->current_picture_ptr->f.motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx;
698
+                s->current_picture_ptr->f.motion_val[k][mv_pos + i + j*s->b8_stride][1] = my;
699 699
             }
700 700
         }
701 701
     }
... ...
@@ -733,24 +733,24 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
733 733
 
734 734
     if(thirdpel){
735 735
         int chroma_mx, chroma_my;
736
-        mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24);
737
-        my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24);
738
-        lx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) % 3;
739
-        ly = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) % 3;
740
-        chroma_mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + 1) >> 1;
741
-        chroma_my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + 1) >> 1;
736
+        mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24);
737
+        my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24);
738
+        lx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) % 3;
739
+        ly = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) % 3;
740
+        chroma_mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + 1) >> 1;
741
+        chroma_my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + 1) >> 1;
742 742
         umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24);
743 743
         umy = (chroma_my + (3 << 24)) / 3 - (1 << 24);
744 744
         uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3];
745 745
         uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3];
746 746
     }else{
747 747
         int cx, cy;
748
-        mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2;
749
-        my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2;
750
-        lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3;
751
-        ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3;
752
-        cx = s->current_picture_ptr->motion_val[dir][mv_pos][0] / 2;
753
-        cy = s->current_picture_ptr->motion_val[dir][mv_pos][1] / 2;
748
+        mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] >> 2;
749
+        my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] >> 2;
750
+        lx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] & 3;
751
+        ly = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] & 3;
752
+        cx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2;
753
+        cy = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2;
754 754
         umx = cx >> 2;
755 755
         umy = cy >> 2;
756 756
         uvmx = (cx & 3) << 1;
... ...
@@ -760,9 +760,9 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
760 760
             uvmx = uvmy = 4;
761 761
     }
762 762
     dxy = ly*4 + lx;
763
-    srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0];
764
-    srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1];
765
-    srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2];
763
+    srcY = dir ? s->next_picture_ptr->f.data[0] : s->last_picture_ptr->f.data[0];
764
+    srcU = dir ? s->next_picture_ptr->f.data[1] : s->last_picture_ptr->f.data[1];
765
+    srcV = dir ? s->next_picture_ptr->f.data[2] : s->last_picture_ptr->f.data[2];
766 766
     src_x = s->mb_x * 16 + xoff + mx;
767 767
     src_y = s->mb_y * 16 + yoff + my;
768 768
     uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx;
... ...
@@ -870,31 +870,31 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type)
870 870
     switch(block_type){
871 871
     case RV34_MB_TYPE_INTRA:
872 872
     case RV34_MB_TYPE_INTRA16x16:
873
-        ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
873
+        ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
874 874
         return 0;
875 875
     case RV34_MB_SKIP:
876 876
         if(s->pict_type == AV_PICTURE_TYPE_P){
877
-            ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
877
+            ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
878 878
             rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0);
879 879
             break;
880 880
         }
881 881
     case RV34_MB_B_DIRECT:
882 882
         //surprisingly, it uses motion scheme from next reference frame
883
-        next_bt = s->next_picture_ptr->mb_type[s->mb_x + s->mb_y * s->mb_stride];
883
+        next_bt = s->next_picture_ptr->f.mb_type[s->mb_x + s->mb_y * s->mb_stride];
884 884
         if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){
885
-            ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
886
-            ZERO8x2(s->current_picture_ptr->motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
885
+            ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
886
+            ZERO8x2(s->current_picture_ptr->f.motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
887 887
         }else
888 888
             for(j = 0; j < 2; j++)
889 889
                 for(i = 0; i < 2; i++)
890 890
                     for(k = 0; k < 2; k++)
891 891
                         for(l = 0; l < 2; l++)
892
-                            s->current_picture_ptr->motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][k]);
892
+                            s->current_picture_ptr->f.motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][k]);
893 893
         if(!(IS_16X8(next_bt) || IS_8X16(next_bt) || IS_8X8(next_bt))) //we can use whole macroblock MC
894 894
             rv34_mc_2mv(r, block_type);
895 895
         else
896 896
             rv34_mc_2mv_skip(r);
897
-        ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
897
+        ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
898 898
         break;
899 899
     case RV34_MB_P_16x16:
900 900
     case RV34_MB_P_MIX16x16:
... ...
@@ -1128,7 +1128,7 @@ static int rv34_set_deblock_coef(RV34DecContext *r)
1128 1128
     MpegEncContext *s = &r->s;
1129 1129
     int hmvmask = 0, vmvmask = 0, i, j;
1130 1130
     int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
1131
-    int16_t (*motion_val)[2] = &s->current_picture_ptr->motion_val[0][midx];
1131
+    int16_t (*motion_val)[2] = &s->current_picture_ptr->f.motion_val[0][midx];
1132 1132
     for(j = 0; j < 16; j += 8){
1133 1133
         for(i = 0; i < 2; i++){
1134 1134
             if(is_mv_diff_gt_3(motion_val + i, 1))
... ...
@@ -1170,14 +1170,14 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
1170 1170
     dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width;
1171 1171
     if(s->mb_x && dist)
1172 1172
         r->avail_cache[5] =
1173
-        r->avail_cache[9] = s->current_picture_ptr->mb_type[mb_pos - 1];
1173
+        r->avail_cache[9] = s->current_picture_ptr->f.mb_type[mb_pos - 1];
1174 1174
     if(dist >= s->mb_width)
1175 1175
         r->avail_cache[2] =
1176
-        r->avail_cache[3] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride];
1176
+        r->avail_cache[3] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride];
1177 1177
     if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1)
1178
-        r->avail_cache[4] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride + 1];
1178
+        r->avail_cache[4] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride + 1];
1179 1179
     if(s->mb_x && dist > s->mb_width)
1180
-        r->avail_cache[1] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride - 1];
1180
+        r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1];
1181 1181
 
1182 1182
     s->qscale = r->si.quant;
1183 1183
     cbp = cbp2 = rv34_decode_mb_header(r, intra_types);
... ...
@@ -1187,7 +1187,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
1187 1187
         r->deblock_coefs[mb_pos] = 0xFFFF;
1188 1188
     else
1189 1189
         r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos];
1190
-    s->current_picture_ptr->qscale_table[mb_pos] = s->qscale;
1190
+    s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
1191 1191
 
1192 1192
     if(cbp == -1)
1193 1193
         return -1;
... ...
@@ -1221,7 +1221,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
1221 1221
         rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]);
1222 1222
         rv34_inv_transform(s->block[blknum] + blkoff);
1223 1223
     }
1224
-    if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos]))
1224
+    if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos]))
1225 1225
         rv34_output_macroblock(r, intra_types, cbp2, r->is16);
1226 1226
     else
1227 1227
         rv34_apply_differences(r, cbp2);
... ...
@@ -1429,7 +1429,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
1429 1429
         av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
1430 1430
         return -1;
1431 1431
     }
1432
-    if((!s->last_picture_ptr || !s->last_picture_ptr->data[0]) && si.type == AV_PICTURE_TYPE_B)
1432
+    if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B)
1433 1433
         return -1;
1434 1434
     if(   (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B)
1435 1435
        || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I)
... ...
@@ -475,7 +475,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
475 475
 
476 476
     mb_pos = row * s->mb_stride;
477 477
     for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
478
-        int mbtype = s->current_picture_ptr->mb_type[mb_pos];
478
+        int mbtype = s->current_picture_ptr->f.mb_type[mb_pos];
479 479
         if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype))
480 480
             r->cbp_luma  [mb_pos] = r->deblock_coefs[mb_pos] = 0xFFFF;
481 481
         if(IS_INTRA(mbtype))
... ...
@@ -489,7 +489,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
489 489
         int avail[4];
490 490
         int y_to_deblock, c_to_deblock[2];
491 491
 
492
-        q = s->current_picture_ptr->qscale_table[mb_pos];
492
+        q = s->current_picture_ptr->f.qscale_table[mb_pos];
493 493
         alpha = rv40_alpha_tab[q];
494 494
         beta  = rv40_beta_tab [q];
495 495
         betaY = betaC = beta * 3;
... ...
@@ -504,7 +504,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
504 504
             if(avail[i]){
505 505
                 int pos = mb_pos + neighbour_offs_x[i] + neighbour_offs_y[i]*s->mb_stride;
506 506
                 mvmasks[i] = r->deblock_coefs[pos];
507
-                mbtype [i] = s->current_picture_ptr->mb_type[pos];
507
+                mbtype [i] = s->current_picture_ptr->f.mb_type[pos];
508 508
                 cbp    [i] = r->cbp_luma[pos];
509 509
                 uvcbp[i][0] = r->cbp_chroma[pos] & 0xF;
510 510
                 uvcbp[i][1] = r->cbp_chroma[pos] >> 4;
... ...
@@ -563,7 +563,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
563 563
         }
564 564
 
565 565
         for(j = 0; j < 16; j += 4){
566
-            Y = s->current_picture_ptr->data[0] + mb_x*16 + (row*16 + j) * s->linesize;
566
+            Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize;
567 567
             for(i = 0; i < 4; i++, Y += 4){
568 568
                 int ij = i + j;
569 569
                 int clip_cur = y_to_deblock & (MASK_CUR << ij) ? clip[POS_CUR] : 0;
... ...
@@ -607,7 +607,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
607 607
         }
608 608
         for(k = 0; k < 2; k++){
609 609
             for(j = 0; j < 2; j++){
610
-                C = s->current_picture_ptr->data[k+1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize;
610
+                C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize;
611 611
                 for(i = 0; i < 2; i++, C += 4){
612 612
                     int ij = i + j*2;
613 613
                     int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0;
... ...
@@ -3441,8 +3441,8 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
3441 3441
     frame_start(s);
3442 3442
 
3443 3443
     s->m.current_picture_ptr= &s->m.current_picture;
3444
-    s->m.last_picture.pts= s->m.current_picture.pts;
3445
-    s->m.current_picture.pts= pict->pts;
3444
+    s->m.last_picture.f.pts = s->m.current_picture.f.pts;
3445
+    s->m.current_picture.f.pts = pict->pts;
3446 3446
     if(pict->pict_type == AV_PICTURE_TYPE_P){
3447 3447
         int block_width = (width +15)>>4;
3448 3448
         int block_height= (height+15)>>4;
... ...
@@ -3452,14 +3452,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
3452 3452
         assert(s->last_picture[0].data[0]);
3453 3453
 
3454 3454
         s->m.avctx= s->avctx;
3455
-        s->m.current_picture.data[0]= s->current_picture.data[0];
3456
-        s->m.   last_picture.data[0]= s->last_picture[0].data[0];
3457
-        s->m.    new_picture.data[0]= s->  input_picture.data[0];
3455
+        s->m.current_picture.f.data[0] = s->current_picture.data[0];
3456
+        s->m.   last_picture.f.data[0] = s->last_picture[0].data[0];
3457
+        s->m.    new_picture.f.data[0] = s->  input_picture.data[0];
3458 3458
         s->m.   last_picture_ptr= &s->m.   last_picture;
3459 3459
         s->m.linesize=
3460
-        s->m.   last_picture.linesize[0]=
3461
-        s->m.    new_picture.linesize[0]=
3462
-        s->m.current_picture.linesize[0]= stride;
3460
+        s->m.   last_picture.f.linesize[0] =
3461
+        s->m.    new_picture.f.linesize[0] =
3462
+        s->m.current_picture.f.linesize[0] = stride;
3463 3463
         s->m.uvlinesize= s->current_picture.linesize[1];
3464 3464
         s->m.width = width;
3465 3465
         s->m.height= height;
... ...
@@ -3646,9 +3646,9 @@ redo_frame:
3646 3646
     s->current_picture.quality = pict->quality;
3647 3647
     s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start);
3648 3648
     s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits;
3649
-    s->m.current_picture.display_picture_number =
3650
-    s->m.current_picture.coded_picture_number = avctx->frame_number;
3651
-    s->m.current_picture.quality = pict->quality;
3649
+    s->m.current_picture.f.display_picture_number =
3650
+    s->m.current_picture.f.coded_picture_number   = avctx->frame_number;
3651
+    s->m.current_picture.f.quality                = pict->quality;
3652 3652
     s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start);
3653 3653
     if(s->pass1_rc)
3654 3654
         if (ff_rate_estimate_qscale(&s->m, 0) < 0)
... ...
@@ -689,12 +689,12 @@ static int svq1_decode_frame(AVCodecContext *avctx,
689 689
       linesize= s->uvlinesize;
690 690
     }
691 691
 
692
-    current  = s->current_picture.data[i];
692
+    current = s->current_picture.f.data[i];
693 693
 
694 694
     if(s->pict_type==AV_PICTURE_TYPE_B){
695
-        previous = s->next_picture.data[i];
695
+        previous = s->next_picture.f.data[i];
696 696
     }else{
697
-        previous = s->last_picture.data[i];
697
+        previous = s->last_picture.f.data[i];
698 698
     }
699 699
 
700 700
     if (s->pict_type == AV_PICTURE_TYPE_I) {
... ...
@@ -284,11 +284,11 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
284 284
         s->m.avctx= s->avctx;
285 285
         s->m.current_picture_ptr= &s->m.current_picture;
286 286
         s->m.last_picture_ptr   = &s->m.last_picture;
287
-        s->m.last_picture.data[0]= ref_plane;
287
+        s->m.last_picture.f.data[0] = ref_plane;
288 288
         s->m.linesize=
289
-        s->m.last_picture.linesize[0]=
290
-        s->m.new_picture.linesize[0]=
291
-        s->m.current_picture.linesize[0]= stride;
289
+        s->m.last_picture.f.linesize[0] =
290
+        s->m.new_picture.f.linesize[0] =
291
+        s->m.current_picture.f.linesize[0] = stride;
292 292
         s->m.width= width;
293 293
         s->m.height= height;
294 294
         s->m.mb_width= block_width;
... ...
@@ -318,9 +318,9 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
318 318
         s->m.current_picture.mb_mean=   (uint8_t *)s->dummy;
319 319
         s->m.current_picture.mb_var=    (uint16_t*)s->dummy;
320 320
         s->m.current_picture.mc_mb_var= (uint16_t*)s->dummy;
321
-        s->m.current_picture.mb_type= s->dummy;
321
+        s->m.current_picture.f.mb_type = s->dummy;
322 322
 
323
-        s->m.current_picture.motion_val[0]= s->motion_val8[plane] + 2;
323
+        s->m.current_picture.f.motion_val[0] = s->motion_val8[plane] + 2;
324 324
         s->m.p_mv_table= s->motion_val16[plane] + s->m.mb_stride + 1;
325 325
         s->m.dsp= s->dsp; //move
326 326
         ff_init_me(&s->m);
... ...
@@ -328,7 +328,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
328 328
         s->m.me.dia_size= s->avctx->dia_size;
329 329
         s->m.first_slice_line=1;
330 330
         for (y = 0; y < block_height; y++) {
331
-            s->m.new_picture.data[0]= src - y*16*stride; //ugly
331
+            s->m.new_picture.f.data[0] = src - y*16*stride; //ugly
332 332
             s->m.mb_y= y;
333 333
 
334 334
             for(i=0; i<16 && i + 16*y<height; i++){
... ...
@@ -290,8 +290,8 @@ static inline void svq3_mc_dir_part(MpegEncContext *s,
290 290
     }
291 291
 
292 292
     /* form component predictions */
293
-    dest = s->current_picture.data[0] + x + y*s->linesize;
294
-    src  = pic->data[0] + mx + my*s->linesize;
293
+    dest = s->current_picture.f.data[0] + x + y*s->linesize;
294
+    src  = pic->f.data[0] + mx + my*s->linesize;
295 295
 
296 296
     if (emu) {
297 297
         s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1),
... ...
@@ -311,8 +311,8 @@ static inline void svq3_mc_dir_part(MpegEncContext *s,
311 311
         blocksize++;
312 312
 
313 313
         for (i = 1; i < 3; i++) {
314
-            dest = s->current_picture.data[i] + (x >> 1) + (y >> 1)*s->uvlinesize;
315
-            src  = pic->data[i] + mx + my*s->uvlinesize;
314
+            dest = s->current_picture.f.data[i] + (x >> 1) + (y >> 1) * s->uvlinesize;
315
+            src  = pic->f.data[i] + mx + my * s->uvlinesize;
316 316
 
317 317
             if (emu) {
318 318
                 s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1),
... ...
@@ -349,8 +349,8 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir,
349 349
             if (mode != PREDICT_MODE) {
350 350
                 pred_motion(h, k, (part_width >> 2), dir, 1, &mx, &my);
351 351
             } else {
352
-                mx = s->next_picture.motion_val[0][b_xy][0]<<1;
353
-                my = s->next_picture.motion_val[0][b_xy][1]<<1;
352
+                mx = s->next_picture.f.motion_val[0][b_xy][0] << 1;
353
+                my = s->next_picture.f.motion_val[0][b_xy][1] << 1;
354 354
 
355 355
                 if (dir == 0) {
356 356
                     mx = ((mx * h->frame_num_offset) / h->prev_frame_num_offset + 1) >> 1;
... ...
@@ -427,7 +427,9 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir,
427 427
             }
428 428
 
429 429
             /* write back motion vectors */
430
-            fill_rectangle(s->current_picture.motion_val[dir][b_xy], part_width>>2, part_height>>2, h->b_stride, pack16to32(mx,my), 4);
430
+            fill_rectangle(s->current_picture.f.motion_val[dir][b_xy],
431
+                           part_width >> 2, part_height >> 2, h->b_stride,
432
+                           pack16to32(mx, my), 4);
431 433
         }
432 434
     }
433 435
 
... ...
@@ -450,7 +452,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
450 450
     h->topright_samples_available = 0xFFFF;
451 451
 
452 452
     if (mb_type == 0) {           /* SKIP */
453
-        if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.mb_type[mb_xy] == -1) {
453
+        if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.f.mb_type[mb_xy] == -1) {
454 454
             svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0);
455 455
 
456 456
             if (s->pict_type == AV_PICTURE_TYPE_B) {
... ...
@@ -459,7 +461,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
459 459
 
460 460
             mb_type = MB_TYPE_SKIP;
461 461
         } else {
462
-            mb_type = FFMIN(s->next_picture.mb_type[mb_xy], 6);
462
+            mb_type = FFMIN(s->next_picture.f.mb_type[mb_xy], 6);
463 463
             if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0)
464 464
                 return -1;
465 465
             if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0)
... ...
@@ -488,7 +490,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
488 488
         for (m = 0; m < 2; m++) {
489 489
             if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {
490 490
                 for (i = 0; i < 4; i++) {
491
-                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride];
491
+                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride];
492 492
                 }
493 493
             } else {
494 494
                 for (i = 0; i < 4; i++) {
... ...
@@ -496,18 +498,18 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
496 496
                 }
497 497
             }
498 498
             if (s->mb_y > 0) {
499
-                memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
499
+                memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
500 500
                 memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
501 501
 
502 502
                 if (s->mb_x < (s->mb_width - 1)) {
503
-                    *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4];
503
+                    *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4];
504 504
                     h->ref_cache[m][scan8[0] + 4 - 1*8] =
505 505
                         (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||
506 506
                          h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride    ]  ] == -1) ? PART_NOT_AVAILABLE : 1;
507 507
                 }else
508 508
                     h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
509 509
                 if (s->mb_x > 0) {
510
-                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1];
510
+                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1];
511 511
                     h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1;
512 512
                 }else
513 513
                     h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;
... ...
@@ -528,7 +530,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
528 528
                     return -1;
529 529
             } else {
530 530
                 for (i = 0; i < 4; i++) {
531
-                    memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
531
+                    memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
532 532
                 }
533 533
             }
534 534
             if (mb_type != 1) {
... ...
@@ -536,7 +538,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
536 536
                     return -1;
537 537
             } else {
538 538
                 for (i = 0; i < 4; i++) {
539
-                    memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
539
+                    memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
540 540
                 }
541 541
             }
542 542
         }
... ...
@@ -623,11 +625,11 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
623 623
 
624 624
     if (!IS_INTER(mb_type) && s->pict_type != AV_PICTURE_TYPE_I) {
625 625
         for (i = 0; i < 4; i++) {
626
-            memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
626
+            memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
627 627
         }
628 628
         if (s->pict_type == AV_PICTURE_TYPE_B) {
629 629
             for (i = 0; i < 4; i++) {
630
-                memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
630
+                memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
631 631
             }
632 632
         }
633 633
     }
... ...
@@ -708,7 +710,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
708 708
     }
709 709
 
710 710
     h->cbp= cbp;
711
-    s->current_picture.mb_type[mb_xy] = mb_type;
711
+    s->current_picture.f.mb_type[mb_xy] = mb_type;
712 712
 
713 713
     if (IS_INTRA(mb_type)) {
714 714
         h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8);
... ...
@@ -980,8 +982,8 @@ static int svq3_decode_frame(AVCodecContext *avctx,
980 980
     }
981 981
 
982 982
     /* for skipping the frame */
983
-    s->current_picture.pict_type = s->pict_type;
984
-    s->current_picture.key_frame = (s->pict_type == AV_PICTURE_TYPE_I);
983
+    s->current_picture.f.pict_type = s->pict_type;
984
+    s->current_picture.f.key_frame = (s->pict_type == AV_PICTURE_TYPE_I);
985 985
 
986 986
     /* Skip B-frames if we do not have reference frames. */
987 987
     if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B)
... ...
@@ -1065,7 +1067,7 @@ static int svq3_decode_frame(AVCodecContext *avctx,
1065 1065
             }
1066 1066
 
1067 1067
             if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay) {
1068
-                s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
1068
+                s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
1069 1069
                     (s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
1070 1070
             }
1071 1071
         }
... ...
@@ -1159,7 +1159,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
1159 1159
 {
1160 1160
     if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
1161 1161
         ff_thread_flush(avctx);
1162
-    if(avctx->codec->flush)
1162
+    else if(avctx->codec->flush)
1163 1163
         avctx->codec->flush(avctx);
1164 1164
 }
1165 1165
 
... ...
@@ -54,7 +54,7 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic,
54 54
                            int            pic_structure)
55 55
 {
56 56
     if (pic_structure == 0)
57
-        pic_structure = pic->reference;
57
+        pic_structure = pic->f.reference;
58 58
     pic_structure &= PICT_FRAME; /* PICT_TOP_FIELD|PICT_BOTTOM_FIELD */
59 59
 
60 60
     va_pic->picture_id = ff_vaapi_get_surface_id(pic);
... ...
@@ -63,7 +63,7 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic,
63 63
     va_pic->flags      = 0;
64 64
     if (pic_structure != PICT_FRAME)
65 65
         va_pic->flags |= (pic_structure & PICT_TOP_FIELD) ? VA_PICTURE_H264_TOP_FIELD : VA_PICTURE_H264_BOTTOM_FIELD;
66
-    if (pic->reference)
66
+    if (pic->f.reference)
67 67
         va_pic->flags |= pic->long_ref ? VA_PICTURE_H264_LONG_TERM_REFERENCE : VA_PICTURE_H264_SHORT_TERM_REFERENCE;
68 68
 
69 69
     va_pic->TopFieldOrderCnt = 0;
... ...
@@ -133,13 +133,13 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param,
133 133
 
134 134
     for (i = 0; i < h->short_ref_count; i++) {
135 135
         Picture * const pic = h->short_ref[i];
136
-        if (pic && pic->reference && dpb_add(&dpb, pic) < 0)
136
+        if (pic && pic->f.reference && dpb_add(&dpb, pic) < 0)
137 137
             return -1;
138 138
     }
139 139
 
140 140
     for (i = 0; i < 16; i++) {
141 141
         Picture * const pic = h->long_ref[i];
142
-        if (pic && pic->reference && dpb_add(&dpb, pic) < 0)
142
+        if (pic && pic->f.reference && dpb_add(&dpb, pic) < 0)
143 143
             return -1;
144 144
     }
145 145
     return 0;
... ...
@@ -159,7 +159,7 @@ static void fill_vaapi_RefPicList(VAPictureH264 RefPicList[32],
159 159
 {
160 160
     unsigned int i, n = 0;
161 161
     for (i = 0; i < ref_count; i++)
162
-        if (ref_list[i].reference)
162
+        if (ref_list[i].f.reference)
163 163
             fill_vaapi_pic(&RefPicList[n++], &ref_list[i], 0);
164 164
 
165 165
     for (; n < 32; n++)
... ...
@@ -38,7 +38,7 @@
38 38
 /** Extract VASurfaceID from a Picture */
39 39
 static inline VASurfaceID ff_vaapi_get_surface_id(Picture *pic)
40 40
 {
41
-    return (uintptr_t)pic->data[3];
41
+    return (uintptr_t)pic->f.data[3];
42 42
 }
43 43
 
44 44
 /** Common AVHWAccel.end_frame() implementation */
... ...
@@ -79,7 +79,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
79 79
     pic_param->quant_precision                          = s->quant_precision;
80 80
     pic_param->vop_fields.value                         = 0; /* reset all bits */
81 81
     pic_param->vop_fields.bits.vop_coding_type          = s->pict_type - AV_PICTURE_TYPE_I;
82
-    pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.pict_type - AV_PICTURE_TYPE_I : 0;
82
+    pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - AV_PICTURE_TYPE_I : 0;
83 83
     pic_param->vop_fields.bits.vop_rounding_type        = s->no_rounding;
84 84
     pic_param->vop_fields.bits.intra_dc_vlc_thr         = mpeg4_get_intra_dc_vlc_thr(s);
85 85
     pic_param->vop_fields.bits.top_field_first          = s->top_field_first;
... ...
@@ -407,15 +407,15 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
407 407
     uint8_t *srcY, *srcU, *srcV;
408 408
     int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
409 409
 
410
-    if(!v->s.last_picture.data[0])return;
410
+    if(!v->s.last_picture.f.data[0])return;
411 411
 
412 412
     mx = s->mv[dir][0][0];
413 413
     my = s->mv[dir][0][1];
414 414
 
415 415
     // store motion vectors for further use in B frames
416 416
     if(s->pict_type == AV_PICTURE_TYPE_P) {
417
-        s->current_picture.motion_val[1][s->block_index[0]][0] = mx;
418
-        s->current_picture.motion_val[1][s->block_index[0]][1] = my;
417
+        s->current_picture.f.motion_val[1][s->block_index[0]][0] = mx;
418
+        s->current_picture.f.motion_val[1][s->block_index[0]][1] = my;
419 419
     }
420 420
     uvmx = (mx + ((mx & 3) == 3)) >> 1;
421 421
     uvmy = (my + ((my & 3) == 3)) >> 1;
... ...
@@ -426,13 +426,13 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
426 426
         uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1));
427 427
     }
428 428
     if(!dir) {
429
-        srcY = s->last_picture.data[0];
430
-        srcU = s->last_picture.data[1];
431
-        srcV = s->last_picture.data[2];
429
+        srcY = s->last_picture.f.data[0];
430
+        srcU = s->last_picture.f.data[1];
431
+        srcV = s->last_picture.f.data[2];
432 432
     } else {
433
-        srcY = s->next_picture.data[0];
434
-        srcU = s->next_picture.data[1];
435
-        srcV = s->next_picture.data[2];
433
+        srcY = s->next_picture.f.data[0];
434
+        srcU = s->next_picture.f.data[1];
435
+        srcV = s->next_picture.f.data[2];
436 436
     }
437 437
 
438 438
     src_x = s->mb_x * 16 + (mx >> 2);
... ...
@@ -559,10 +559,10 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n)
559 559
     int dxy, mx, my, src_x, src_y;
560 560
     int off;
561 561
 
562
-    if(!v->s.last_picture.data[0])return;
562
+    if(!v->s.last_picture.f.data[0])return;
563 563
     mx = s->mv[0][n][0];
564 564
     my = s->mv[0][n][1];
565
-    srcY = s->last_picture.data[0];
565
+    srcY = s->last_picture.f.data[0];
566 566
 
567 567
     off = s->linesize * 4 * (n&2) + (n&1) * 8;
568 568
 
... ...
@@ -647,7 +647,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
647 647
     int mvx[4], mvy[4], intra[4];
648 648
     static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
649 649
 
650
-    if(!v->s.last_picture.data[0])return;
650
+    if(!v->s.last_picture.f.data[0])return;
651 651
     if(s->flags & CODEC_FLAG_GRAY) return;
652 652
 
653 653
     for(i = 0; i < 4; i++) {
... ...
@@ -687,14 +687,14 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
687 687
         tx = (mvx[t1] + mvx[t2]) / 2;
688 688
         ty = (mvy[t1] + mvy[t2]) / 2;
689 689
     } else {
690
-        s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
691
-        s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
690
+        s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
691
+        s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
692 692
         v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
693 693
         return; //no need to do MC for inter blocks
694 694
     }
695 695
 
696
-    s->current_picture.motion_val[1][s->block_index[0]][0] = tx;
697
-    s->current_picture.motion_val[1][s->block_index[0]][1] = ty;
696
+    s->current_picture.f.motion_val[1][s->block_index[0]][0] = tx;
697
+    s->current_picture.f.motion_val[1][s->block_index[0]][1] = ty;
698 698
     uvmx = (tx + ((tx&3) == 3)) >> 1;
699 699
     uvmy = (ty + ((ty&3) == 3)) >> 1;
700 700
     v->luma_mv[s->mb_x][0] = uvmx;
... ...
@@ -715,8 +715,8 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
715 715
         uvsrc_y = av_clip(uvsrc_y,  -8, s->avctx->coded_height >> 1);
716 716
     }
717 717
 
718
-    srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
719
-    srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
718
+    srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
719
+    srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
720 720
     if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
721 721
        || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
722 722
        || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - 9){
... ...
@@ -883,30 +883,30 @@ static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int m
883 883
     xy = s->block_index[n];
884 884
 
885 885
     if(s->mb_intra){
886
-        s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0;
887
-        s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0;
888
-        s->current_picture.motion_val[1][xy][0] = 0;
889
-        s->current_picture.motion_val[1][xy][1] = 0;
886
+        s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0;
887
+        s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0;
888
+        s->current_picture.f.motion_val[1][xy][0] = 0;
889
+        s->current_picture.f.motion_val[1][xy][1] = 0;
890 890
         if(mv1) { /* duplicate motion data for 1-MV block */
891
-            s->current_picture.motion_val[0][xy + 1][0] = 0;
892
-            s->current_picture.motion_val[0][xy + 1][1] = 0;
893
-            s->current_picture.motion_val[0][xy + wrap][0] = 0;
894
-            s->current_picture.motion_val[0][xy + wrap][1] = 0;
895
-            s->current_picture.motion_val[0][xy + wrap + 1][0] = 0;
896
-            s->current_picture.motion_val[0][xy + wrap + 1][1] = 0;
891
+            s->current_picture.f.motion_val[0][xy + 1][0]        = 0;
892
+            s->current_picture.f.motion_val[0][xy + 1][1]        = 0;
893
+            s->current_picture.f.motion_val[0][xy + wrap][0]     = 0;
894
+            s->current_picture.f.motion_val[0][xy + wrap][1]     = 0;
895
+            s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0;
896
+            s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0;
897 897
             v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
898
-            s->current_picture.motion_val[1][xy + 1][0] = 0;
899
-            s->current_picture.motion_val[1][xy + 1][1] = 0;
900
-            s->current_picture.motion_val[1][xy + wrap][0] = 0;
901
-            s->current_picture.motion_val[1][xy + wrap][1] = 0;
902
-            s->current_picture.motion_val[1][xy + wrap + 1][0] = 0;
903
-            s->current_picture.motion_val[1][xy + wrap + 1][1] = 0;
898
+            s->current_picture.f.motion_val[1][xy + 1][0]        = 0;
899
+            s->current_picture.f.motion_val[1][xy + 1][1]        = 0;
900
+            s->current_picture.f.motion_val[1][xy + wrap][0]     = 0;
901
+            s->current_picture.f.motion_val[1][xy + wrap][1]     = 0;
902
+            s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0;
903
+            s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0;
904 904
         }
905 905
         return;
906 906
     }
907 907
 
908
-    C = s->current_picture.motion_val[0][xy - 1];
909
-    A = s->current_picture.motion_val[0][xy - wrap];
908
+    C = s->current_picture.f.motion_val[0][xy - 1];
909
+    A = s->current_picture.f.motion_val[0][xy - wrap];
910 910
     if(mv1)
911 911
         off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2;
912 912
     else {
... ...
@@ -925,7 +925,7 @@ static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int m
925 925
             off = -1;
926 926
         }
927 927
     }
928
-    B = s->current_picture.motion_val[0][xy - wrap + off];
928
+    B = s->current_picture.f.motion_val[0][xy - wrap + off];
929 929
 
930 930
     if(!s->first_slice_line || (n==2 || n==3)) { // predictor A is not out of bounds
931 931
         if(s->mb_width == 1) {
... ...
@@ -989,15 +989,15 @@ static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int m
989 989
         }
990 990
     }
991 991
     /* store MV using signed modulus of MV range defined in 4.11 */
992
-    s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
993
-    s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;
992
+    s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
993
+    s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;
994 994
     if(mv1) { /* duplicate motion data for 1-MV block */
995
-        s->current_picture.motion_val[0][xy + 1][0] = s->current_picture.motion_val[0][xy][0];
996
-        s->current_picture.motion_val[0][xy + 1][1] = s->current_picture.motion_val[0][xy][1];
997
-        s->current_picture.motion_val[0][xy + wrap][0] = s->current_picture.motion_val[0][xy][0];
998
-        s->current_picture.motion_val[0][xy + wrap][1] = s->current_picture.motion_val[0][xy][1];
999
-        s->current_picture.motion_val[0][xy + wrap + 1][0] = s->current_picture.motion_val[0][xy][0];
1000
-        s->current_picture.motion_val[0][xy + wrap + 1][1] = s->current_picture.motion_val[0][xy][1];
995
+        s->current_picture.f.motion_val[0][xy + 1][0]        = s->current_picture.f.motion_val[0][xy][0];
996
+        s->current_picture.f.motion_val[0][xy + 1][1]        = s->current_picture.f.motion_val[0][xy][1];
997
+        s->current_picture.f.motion_val[0][xy + wrap][0]     = s->current_picture.f.motion_val[0][xy][0];
998
+        s->current_picture.f.motion_val[0][xy + wrap][1]     = s->current_picture.f.motion_val[0][xy][1];
999
+        s->current_picture.f.motion_val[0][xy + wrap + 1][0] = s->current_picture.f.motion_val[0][xy][0];
1000
+        s->current_picture.f.motion_val[0][xy + wrap + 1][1] = s->current_picture.f.motion_val[0][xy][1];
1001 1001
     }
1002 1002
 }
1003 1003
 
... ...
@@ -1010,7 +1010,7 @@ static void vc1_interp_mc(VC1Context *v)
1010 1010
     uint8_t *srcY, *srcU, *srcV;
1011 1011
     int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
1012 1012
 
1013
-    if(!v->s.next_picture.data[0])return;
1013
+    if(!v->s.next_picture.f.data[0])return;
1014 1014
 
1015 1015
     mx = s->mv[1][0][0];
1016 1016
     my = s->mv[1][0][1];
... ...
@@ -1020,9 +1020,9 @@ static void vc1_interp_mc(VC1Context *v)
1020 1020
         uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1));
1021 1021
         uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1));
1022 1022
     }
1023
-    srcY = s->next_picture.data[0];
1024
-    srcU = s->next_picture.data[1];
1025
-    srcV = s->next_picture.data[2];
1023
+    srcY = s->next_picture.f.data[0];
1024
+    srcU = s->next_picture.f.data[1];
1025
+    srcV = s->next_picture.f.data[2];
1026 1026
 
1027 1027
     src_x = s->mb_x * 16 + (mx >> 2);
1028 1028
     src_y = s->mb_y * 16 + (my >> 2);
... ...
@@ -1185,16 +1185,16 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
1185 1185
     xy = s->block_index[0];
1186 1186
 
1187 1187
     if(s->mb_intra) {
1188
-        s->current_picture.motion_val[0][xy][0] =
1189
-        s->current_picture.motion_val[0][xy][1] =
1190
-        s->current_picture.motion_val[1][xy][0] =
1191
-        s->current_picture.motion_val[1][xy][1] = 0;
1188
+        s->current_picture.f.motion_val[0][xy][0] =
1189
+        s->current_picture.f.motion_val[0][xy][1] =
1190
+        s->current_picture.f.motion_val[1][xy][0] =
1191
+        s->current_picture.f.motion_val[1][xy][1] = 0;
1192 1192
         return;
1193 1193
     }
1194
-    s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample);
1195
-    s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample);
1196
-    s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample);
1197
-    s->mv[1][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample);
1194
+    s->mv[0][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample);
1195
+    s->mv[0][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample);
1196
+    s->mv[1][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample);
1197
+    s->mv[1][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample);
1198 1198
 
1199 1199
     /* Pullback predicted motion vectors as specified in 8.4.5.4 */
1200 1200
     s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width  << 6) - 4 - (s->mb_x << 6));
... ...
@@ -1202,18 +1202,18 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
1202 1202
     s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width  << 6) - 4 - (s->mb_x << 6));
1203 1203
     s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6));
1204 1204
     if(direct) {
1205
-        s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0];
1206
-        s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1];
1207
-        s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0];
1208
-        s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1];
1205
+        s->current_picture.f.motion_val[0][xy][0] = s->mv[0][0][0];
1206
+        s->current_picture.f.motion_val[0][xy][1] = s->mv[0][0][1];
1207
+        s->current_picture.f.motion_val[1][xy][0] = s->mv[1][0][0];
1208
+        s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1];
1209 1209
         return;
1210 1210
     }
1211 1211
 
1212 1212
     if((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) {
1213
-        C = s->current_picture.motion_val[0][xy - 2];
1214
-        A = s->current_picture.motion_val[0][xy - wrap*2];
1213
+        C = s->current_picture.f.motion_val[0][xy - 2];
1214
+        A = s->current_picture.f.motion_val[0][xy - wrap*2];
1215 1215
         off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
1216
-        B = s->current_picture.motion_val[0][xy - wrap*2 + off];
1216
+        B = s->current_picture.f.motion_val[0][xy - wrap*2 + off];
1217 1217
 
1218 1218
         if(!s->mb_x) C[0] = C[1] = 0;
1219 1219
         if(!s->first_slice_line) { // predictor A is not out of bounds
... ...
@@ -1288,10 +1288,10 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
1288 1288
         s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
1289 1289
     }
1290 1290
     if((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) {
1291
-        C = s->current_picture.motion_val[1][xy - 2];
1292
-        A = s->current_picture.motion_val[1][xy - wrap*2];
1291
+        C = s->current_picture.f.motion_val[1][xy - 2];
1292
+        A = s->current_picture.f.motion_val[1][xy - wrap*2];
1293 1293
         off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
1294
-        B = s->current_picture.motion_val[1][xy - wrap*2 + off];
1294
+        B = s->current_picture.f.motion_val[1][xy - wrap*2 + off];
1295 1295
 
1296 1296
         if(!s->mb_x) C[0] = C[1] = 0;
1297 1297
         if(!s->first_slice_line) { // predictor A is not out of bounds
... ...
@@ -1366,10 +1366,10 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
1366 1366
         s->mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
1367 1367
         s->mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
1368 1368
     }
1369
-    s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0];
1370
-    s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1];
1371
-    s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0];
1372
-    s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1];
1369
+    s->current_picture.f.motion_val[0][xy][0] = s->mv[0][0][0];
1370
+    s->current_picture.f.motion_val[0][xy][1] = s->mv[0][0][1];
1371
+    s->current_picture.f.motion_val[1][xy][0] = s->mv[1][0][0];
1372
+    s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1];
1373 1373
 }
1374 1374
 
1375 1375
 /** Get predicted DC value for I-frames only
... ...
@@ -1464,14 +1464,14 @@ static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
1464 1464
     b = dc_val[ - 1 - wrap];
1465 1465
     a = dc_val[ - wrap];
1466 1466
     /* scale predictors if needed */
1467
-    q1 = s->current_picture.qscale_table[mb_pos];
1467
+    q1 = s->current_picture.f.qscale_table[mb_pos];
1468 1468
     if(c_avail && (n!= 1 && n!=3)) {
1469
-        q2 = s->current_picture.qscale_table[mb_pos - 1];
1469
+        q2 = s->current_picture.f.qscale_table[mb_pos - 1];
1470 1470
         if(q2 && q2 != q1)
1471 1471
             c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
1472 1472
     }
1473 1473
     if(a_avail && (n!= 2 && n!=3)) {
1474
-        q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
1474
+        q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
1475 1475
         if(q2 && q2 != q1)
1476 1476
             a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
1477 1477
     }
... ...
@@ -1479,7 +1479,7 @@ static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
1479 1479
         int off = mb_pos;
1480 1480
         if(n != 1) off--;
1481 1481
         if(n != 2) off -= s->mb_stride;
1482
-        q2 = s->current_picture.qscale_table[off];
1482
+        q2 = s->current_picture.f.qscale_table[off];
1483 1483
         if(q2 && q2 != q1)
1484 1484
             b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
1485 1485
     }
... ...
@@ -1853,9 +1853,9 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
1853 1853
     else //top
1854 1854
         ac_val -= 16 * s->block_wrap[n];
1855 1855
 
1856
-    q1 = s->current_picture.qscale_table[mb_pos];
1857
-    if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1];
1858
-    if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
1856
+    q1 = s->current_picture.f.qscale_table[mb_pos];
1857
+    if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1];
1858
+    if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
1859 1859
     if(dc_pred_dir && n==1) q2 = q1;
1860 1860
     if(!dc_pred_dir && n==2) q2 = q1;
1861 1861
     if(n==3) q2 = q1;
... ...
@@ -2060,9 +2060,9 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
2060 2060
     else //top
2061 2061
         ac_val -= 16 * s->block_wrap[n];
2062 2062
 
2063
-    q1 = s->current_picture.qscale_table[mb_pos];
2064
-    if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1];
2065
-    if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
2063
+    q1 = s->current_picture.f.qscale_table[mb_pos];
2064
+    if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1];
2065
+    if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
2066 2066
     if(dc_pred_dir && n==1) q2 = q1;
2067 2067
     if(!dc_pred_dir && n==2) q2 = q1;
2068 2068
     if(n==3) q2 = q1;
... ...
@@ -2344,7 +2344,7 @@ static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_
2344 2344
             bottom_is_intra = (block_num < 2) ? (mb_is_intra          >> ((block_num + 2) * 4)) :
2345 2345
                                                 (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));
2346 2346
             mv_stride       = s->b8_stride;
2347
-            mv              = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * mv_stride];
2347
+            mv              = &s->current_picture.f.motion_val[0][s->block_index[block_num] - 2 * mv_stride];
2348 2348
         }
2349 2349
 
2350 2350
         if (bottom_is_intra & 1 || block_is_intra & 1 ||
... ...
@@ -2406,7 +2406,7 @@ static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_
2406 2406
                                                (mb_cbp                              >> ((block_num + 1) * 4));
2407 2407
             right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) :
2408 2408
                                                (mb_is_intra                         >> ((block_num + 1) * 4));
2409
-            mv             = &s->current_picture.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2];
2409
+            mv             = &s->current_picture.f.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2];
2410 2410
         }
2411 2411
         if (block_is_intra & 1 || right_is_intra & 1 || mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1]) {
2412 2412
             v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
... ...
@@ -2502,10 +2502,10 @@ static int vc1_decode_p_mb(VC1Context *v)
2502 2502
             GET_MVDATA(dmv_x, dmv_y);
2503 2503
 
2504 2504
             if (s->mb_intra) {
2505
-                s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
2506
-                s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
2505
+                s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
2506
+                s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
2507 2507
             }
2508
-            s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
2508
+            s->current_picture.f.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
2509 2509
             vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
2510 2510
 
2511 2511
             /* FIXME Set DC val for inter block ? */
... ...
@@ -2526,7 +2526,7 @@ static int vc1_decode_p_mb(VC1Context *v)
2526 2526
                 mquant = v->pq;
2527 2527
                 cbp = 0;
2528 2528
             }
2529
-            s->current_picture.qscale_table[mb_pos] = mquant;
2529
+            s->current_picture.f.qscale_table[mb_pos] = mquant;
2530 2530
 
2531 2531
             if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
2532 2532
                 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,
... ...
@@ -2576,8 +2576,8 @@ static int vc1_decode_p_mb(VC1Context *v)
2576 2576
                 v->mb_type[0][s->block_index[i]] = 0;
2577 2577
                 s->dc_val[0][s->block_index[i]] = 0;
2578 2578
             }
2579
-            s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
2580
-            s->current_picture.qscale_table[mb_pos] = 0;
2579
+            s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP;
2580
+            s->current_picture.f.qscale_table[mb_pos] = 0;
2581 2581
             vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
2582 2582
             vc1_mc_1mv(v, 0);
2583 2583
         }
... ...
@@ -2621,7 +2621,7 @@ static int vc1_decode_p_mb(VC1Context *v)
2621 2621
             if(!intra_count && !coded_inter)
2622 2622
                 goto end;
2623 2623
             GET_MQUANT();
2624
-            s->current_picture.qscale_table[mb_pos] = mquant;
2624
+            s->current_picture.f.qscale_table[mb_pos] = mquant;
2625 2625
             /* test if block is intra and has pred */
2626 2626
             {
2627 2627
                 int intrapred = 0;
... ...
@@ -2675,7 +2675,7 @@ static int vc1_decode_p_mb(VC1Context *v)
2675 2675
         else //Skipped MB
2676 2676
         {
2677 2677
             s->mb_intra = 0;
2678
-            s->current_picture.qscale_table[mb_pos] = 0;
2678
+            s->current_picture.f.qscale_table[mb_pos] = 0;
2679 2679
             for (i=0; i<6; i++) {
2680 2680
                 v->mb_type[0][s->block_index[i]] = 0;
2681 2681
                 s->dc_val[0][s->block_index[i]] = 0;
... ...
@@ -2686,7 +2686,7 @@ static int vc1_decode_p_mb(VC1Context *v)
2686 2686
                 vc1_mc_4mv_luma(v, i);
2687 2687
             }
2688 2688
             vc1_mc_4mv_chroma(v);
2689
-            s->current_picture.qscale_table[mb_pos] = 0;
2689
+            s->current_picture.f.qscale_table[mb_pos] = 0;
2690 2690
         }
2691 2691
     }
2692 2692
 end:
... ...
@@ -2734,7 +2734,7 @@ static void vc1_decode_b_mb(VC1Context *v)
2734 2734
         v->mb_type[0][s->block_index[i]] = 0;
2735 2735
         s->dc_val[0][s->block_index[i]] = 0;
2736 2736
     }
2737
-    s->current_picture.qscale_table[mb_pos] = 0;
2737
+    s->current_picture.f.qscale_table[mb_pos] = 0;
2738 2738
 
2739 2739
     if (!direct) {
2740 2740
         if (!skipped) {
... ...
@@ -2770,7 +2770,7 @@ static void vc1_decode_b_mb(VC1Context *v)
2770 2770
         cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
2771 2771
         GET_MQUANT();
2772 2772
         s->mb_intra = 0;
2773
-        s->current_picture.qscale_table[mb_pos] = mquant;
2773
+        s->current_picture.f.qscale_table[mb_pos] = mquant;
2774 2774
         if(!v->ttmbf)
2775 2775
             ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
2776 2776
         dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
... ...
@@ -2785,7 +2785,7 @@ static void vc1_decode_b_mb(VC1Context *v)
2785 2785
         }
2786 2786
         if(s->mb_intra && !mb_has_coeffs) {
2787 2787
             GET_MQUANT();
2788
-            s->current_picture.qscale_table[mb_pos] = mquant;
2788
+            s->current_picture.f.qscale_table[mb_pos] = mquant;
2789 2789
             s->ac_pred = get_bits1(gb);
2790 2790
             cbp = 0;
2791 2791
             vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
... ...
@@ -2807,7 +2807,7 @@ static void vc1_decode_b_mb(VC1Context *v)
2807 2807
                 s->ac_pred = get_bits1(gb);
2808 2808
             cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
2809 2809
             GET_MQUANT();
2810
-            s->current_picture.qscale_table[mb_pos] = mquant;
2810
+            s->current_picture.f.qscale_table[mb_pos] = mquant;
2811 2811
             if(!v->ttmbf && !s->mb_intra && mb_has_coeffs)
2812 2812
                 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
2813 2813
         }
... ...
@@ -2898,10 +2898,10 @@ static void vc1_decode_i_blocks(VC1Context *v)
2898 2898
             dst[5] = s->dest[2];
2899 2899
             s->dsp.clear_blocks(s->block[0]);
2900 2900
             mb_pos = s->mb_x + s->mb_y * s->mb_width;
2901
-            s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
2902
-            s->current_picture.qscale_table[mb_pos] = v->pq;
2903
-            s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
2904
-            s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
2901
+            s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA;
2902
+            s->current_picture.f.qscale_table[mb_pos] = v->pq;
2903
+            s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
2904
+            s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
2905 2905
 
2906 2906
             // do actual MB decoding and displaying
2907 2907
             cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
... ...
@@ -3029,9 +3029,9 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
3029 3029
             ff_update_block_index(s);
3030 3030
             s->dsp.clear_blocks(block[0]);
3031 3031
             mb_pos = s->mb_x + s->mb_y * s->mb_stride;
3032
-            s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
3033
-            s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
3034
-            s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
3032
+            s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA;
3033
+            s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
3034
+            s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
3035 3035
 
3036 3036
             // do actual MB decoding and displaying
3037 3037
             cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
... ...
@@ -3045,7 +3045,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
3045 3045
 
3046 3046
             GET_MQUANT();
3047 3047
 
3048
-            s->current_picture.qscale_table[mb_pos] = mquant;
3048
+            s->current_picture.f.qscale_table[mb_pos] = mquant;
3049 3049
             /* Set DC scale - y and c use the same */
3050 3050
             s->y_dc_scale = s->y_dc_scale_table[mquant];
3051 3051
             s->c_dc_scale = s->c_dc_scale_table[mquant];
... ...
@@ -3232,9 +3232,9 @@ static void vc1_decode_skip_blocks(VC1Context *v)
3232 3232
         s->mb_x = 0;
3233 3233
         ff_init_block_index(s);
3234 3234
         ff_update_block_index(s);
3235
-        memcpy(s->dest[0], s->last_picture.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
3236
-        memcpy(s->dest[1], s->last_picture.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
3237
-        memcpy(s->dest[2], s->last_picture.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
3235
+        memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize,   s->linesize   * 16);
3236
+        memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
3237
+        memcpy(s->dest[2], s->last_picture.f.data[2] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
3238 3238
         ff_draw_horiz_band(s, s->mb_y * 16, 16);
3239 3239
         s->first_slice_line = 0;
3240 3240
     }
... ...
@@ -3601,7 +3601,7 @@ static int vc1_decode_frame(AVCodecContext *avctx,
3601 3601
 
3602 3602
     /* We need to set current_picture_ptr before reading the header,
3603 3603
      * otherwise we cannot store anything in there. */
3604
-    if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
3604
+    if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
3605 3605
         int i= ff_find_unused_picture(s, 0);
3606 3606
         s->current_picture_ptr= &s->picture[i];
3607 3607
     }
... ...
@@ -3698,18 +3698,18 @@ static int vc1_decode_frame(AVCodecContext *avctx,
3698 3698
         av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n");
3699 3699
     }
3700 3700
 
3701
-    s->current_picture_ptr->repeat_pict = 0;
3701
+    s->current_picture_ptr->f.repeat_pict = 0;
3702 3702
     if (v->rff){
3703
-        s->current_picture_ptr->repeat_pict = 1;
3703
+        s->current_picture_ptr->f.repeat_pict = 1;
3704 3704
     }else if (v->rptfrm){
3705
-        s->current_picture_ptr->repeat_pict = v->rptfrm * 2;
3705
+        s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
3706 3706
     }
3707 3707
 
3708
-    s->current_picture_ptr->top_field_first = v->tff;
3708
+    s->current_picture_ptr->f.top_field_first = v->tff;
3709 3709
 
3710 3710
     // for skipping the frame
3711
-    s->current_picture.pict_type= s->pict_type;
3712
-    s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I;
3711
+    s->current_picture.f.pict_type = s->pict_type;
3712
+    s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
3713 3713
 
3714 3714
     /* skip B-frames if we don't have reference frames */
3715 3715
     if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)){
... ...
@@ -3765,8 +3765,8 @@ static int vc1_decode_frame(AVCodecContext *avctx,
3765 3765
 
3766 3766
     MPV_frame_end(s);
3767 3767
 
3768
-assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
3769
-assert(s->current_picture.pict_type == s->pict_type);
3768
+assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
3769
+assert(s->current_picture.f.pict_type == s->pict_type);
3770 3770
     if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
3771 3771
         *pict= *(AVFrame*)s->current_picture_ptr;
3772 3772
     } else if (s->last_picture_ptr != NULL) {
... ...
@@ -46,7 +46,7 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
46 46
     Picture *pic;
47 47
     int i, list, pic_frame_idx;
48 48
 
49
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
49
+    render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
50 50
     assert(render);
51 51
 
52 52
     rf = &render->info.h264.referenceFrames[0];
... ...
@@ -58,11 +58,11 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
58 58
 
59 59
         for (i = 0; i < ls; ++i) {
60 60
             pic = lp[i];
61
-            if (!pic || !pic->reference)
61
+            if (!pic || !pic->f.reference)
62 62
                 continue;
63 63
             pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
64 64
 
65
-            render_ref = (struct vdpau_render_state *)pic->data[0];
65
+            render_ref = (struct vdpau_render_state *)pic->f.data[0];
66 66
             assert(render_ref);
67 67
 
68 68
             rf2 = &render->info.h264.referenceFrames[0];
... ...
@@ -76,8 +76,8 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
76 76
                 ++rf2;
77 77
             }
78 78
             if (rf2 != rf) {
79
-                rf2->top_is_reference    |= (pic->reference & PICT_TOP_FIELD)    ? VDP_TRUE : VDP_FALSE;
80
-                rf2->bottom_is_reference |= (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE;
79
+                rf2->top_is_reference    |= (pic->f.reference & PICT_TOP_FIELD)    ? VDP_TRUE : VDP_FALSE;
80
+                rf2->bottom_is_reference |= (pic->f.reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE;
81 81
                 continue;
82 82
             }
83 83
 
... ...
@@ -86,8 +86,8 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
86 86
 
87 87
             rf->surface             = render_ref->surface;
88 88
             rf->is_long_term        = pic->long_ref;
89
-            rf->top_is_reference    = (pic->reference & PICT_TOP_FIELD)    ? VDP_TRUE : VDP_FALSE;
90
-            rf->bottom_is_reference = (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE;
89
+            rf->top_is_reference    = (pic->f.reference & PICT_TOP_FIELD)    ? VDP_TRUE : VDP_FALSE;
90
+            rf->bottom_is_reference = (pic->f.reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE;
91 91
             rf->field_order_cnt[0]  = pic->field_poc[0];
92 92
             rf->field_order_cnt[1]  = pic->field_poc[1];
93 93
             rf->frame_idx           = pic_frame_idx;
... ...
@@ -112,7 +112,7 @@ void ff_vdpau_add_data_chunk(MpegEncContext *s,
112 112
 {
113 113
     struct vdpau_render_state *render;
114 114
 
115
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
115
+    render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
116 116
     assert(render);
117 117
 
118 118
     render->bitstream_buffers= av_fast_realloc(
... ...
@@ -133,7 +133,7 @@ void ff_vdpau_h264_picture_start(MpegEncContext *s)
133 133
     struct vdpau_render_state *render;
134 134
     int i;
135 135
 
136
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
136
+    render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
137 137
     assert(render);
138 138
 
139 139
     for (i = 0; i < 2; ++i) {
... ...
@@ -151,14 +151,14 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s)
151 151
     H264Context *h = s->avctx->priv_data;
152 152
     struct vdpau_render_state *render;
153 153
 
154
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
154
+    render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
155 155
     assert(render);
156 156
 
157 157
     render->info.h264.slice_count = h->slice_num;
158 158
     if (render->info.h264.slice_count < 1)
159 159
         return;
160 160
 
161
-    render->info.h264.is_reference                           = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;
161
+    render->info.h264.is_reference                           = (s->current_picture_ptr->f.reference & 3) ? VDP_TRUE : VDP_FALSE;
162 162
     render->info.h264.field_pic_flag                         = s->picture_structure != PICT_FRAME;
163 163
     render->info.h264.bottom_field_flag                      = s->picture_structure == PICT_BOTTOM_FIELD;
164 164
     render->info.h264.num_ref_frames                         = h->sps.ref_frame_count;
... ...
@@ -198,7 +198,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
198 198
 
199 199
     if (!s->current_picture_ptr) return;
200 200
 
201
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
201
+    render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
202 202
     assert(render);
203 203
 
204 204
     /* fill VdpPictureInfoMPEG1Or2 struct */
... ...
@@ -227,12 +227,12 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
227 227
 
228 228
     switch(s->pict_type){
229 229
     case  AV_PICTURE_TYPE_B:
230
-        next = (struct vdpau_render_state *)s->next_picture.data[0];
230
+        next = (struct vdpau_render_state *)s->next_picture.f.data[0];
231 231
         assert(next);
232 232
         render->info.mpeg.backward_reference     = next->surface;
233 233
         // no return here, going to set forward prediction
234 234
     case  AV_PICTURE_TYPE_P:
235
-        last = (struct vdpau_render_state *)s->last_picture.data[0];
235
+        last = (struct vdpau_render_state *)s->last_picture.f.data[0];
236 236
         if (!last) // FIXME: Does this test make sense?
237 237
             last = render; // predict second field from the first
238 238
         render->info.mpeg.forward_reference      = last->surface;
... ...
@@ -253,7 +253,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
253 253
     VC1Context *v = s->avctx->priv_data;
254 254
     struct vdpau_render_state *render, *last, *next;
255 255
 
256
-    render = (struct vdpau_render_state *)s->current_picture.data[0];
256
+    render = (struct vdpau_render_state *)s->current_picture.f.data[0];
257 257
     assert(render);
258 258
 
259 259
     /*  fill LvPictureInfoVC1 struct */
... ...
@@ -297,12 +297,12 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
297 297
 
298 298
     switch(s->pict_type){
299 299
     case  AV_PICTURE_TYPE_B:
300
-        next = (struct vdpau_render_state *)s->next_picture.data[0];
300
+        next = (struct vdpau_render_state *)s->next_picture.f.data[0];
301 301
         assert(next);
302 302
         render->info.vc1.backward_reference = next->surface;
303 303
         // no break here, going to set forward prediction
304 304
     case  AV_PICTURE_TYPE_P:
305
-        last = (struct vdpau_render_state *)s->last_picture.data[0];
305
+        last = (struct vdpau_render_state *)s->last_picture.f.data[0];
306 306
         if (!last) // FIXME: Does this test make sense?
307 307
             last = render; // predict second field from the first
308 308
         render->info.vc1.forward_reference = last->surface;
... ...
@@ -324,7 +324,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
324 324
 
325 325
     if (!s->current_picture_ptr) return;
326 326
 
327
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
327
+    render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
328 328
     assert(render);
329 329
 
330 330
     /* fill VdpPictureInfoMPEG4Part2 struct */
... ...
@@ -353,13 +353,13 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
353 353
 
354 354
     switch (s->pict_type) {
355 355
     case AV_PICTURE_TYPE_B:
356
-        next = (struct vdpau_render_state *)s->next_picture.data[0];
356
+        next = (struct vdpau_render_state *)s->next_picture.f.data[0];
357 357
         assert(next);
358 358
         render->info.mpeg4.backward_reference     = next->surface;
359 359
         render->info.mpeg4.vop_coding_type        = 2;
360 360
         // no break here, going to set forward prediction
361 361
     case AV_PICTURE_TYPE_P:
362
-        last = (struct vdpau_render_state *)s->last_picture.data[0];
362
+        last = (struct vdpau_render_state *)s->last_picture.f.data[0];
363 363
         assert(last);
364 364
         render->info.mpeg4.forward_reference      = last->surface;
365 365
     }
... ...
@@ -32,7 +32,7 @@
32 32
 static void parse_mb_skip(Wmv2Context * w){
33 33
     int mb_x, mb_y;
34 34
     MpegEncContext * const s= &w->s;
35
-    uint32_t * const mb_type= s->current_picture_ptr->mb_type;
35
+    uint32_t * const mb_type = s->current_picture_ptr->f.mb_type;
36 36
 
37 37
     w->skip_type= get_bits(&s->gb, 2);
38 38
     switch(w->skip_type){
... ...
@@ -257,11 +257,11 @@ static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
257 257
     wrap = s->b8_stride;
258 258
     xy = s->block_index[0];
259 259
 
260
-    mot_val = s->current_picture.motion_val[0][xy];
260
+    mot_val = s->current_picture.f.motion_val[0][xy];
261 261
 
262
-    A = s->current_picture.motion_val[0][xy - 1];
263
-    B = s->current_picture.motion_val[0][xy - wrap];
264
-    C = s->current_picture.motion_val[0][xy + 2 - wrap];
262
+    A = s->current_picture.f.motion_val[0][xy - 1];
263
+    B = s->current_picture.f.motion_val[0][xy - wrap];
264
+    C = s->current_picture.f.motion_val[0][xy + 2 - wrap];
265 265
 
266 266
     if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
267 267
         diff= FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
... ...
@@ -343,7 +343,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
343 343
     if(w->j_type) return 0;
344 344
 
345 345
     if (s->pict_type == AV_PICTURE_TYPE_P) {
346
-        if(IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])){
346
+        if (IS_SKIP(s->current_picture.f.mb_type[s->mb_y * s->mb_stride + s->mb_x])) {
347 347
             /* skip mb */
348 348
             s->mb_intra = 0;
349 349
             for(i=0;i<6;i++)
... ...
@@ -354,10 +354,11 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
354 354
 {
355 355
     int mm_flags = av_get_cpu_flags();
356 356
 
357
-    if (bit_depth == 8) {
358 357
     if (mm_flags & AV_CPU_FLAG_MMX2) {
359 358
         c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
360 359
     }
360
+
361
+    if (bit_depth == 8) {
361 362
 #if HAVE_YASM
362 363
     if (mm_flags & AV_CPU_FLAG_MMX) {
363 364
         c->h264_idct_dc_add         =
... ...
@@ -1269,7 +1269,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
1269 1269
 {
1270 1270
     AVFormatContext *s = ts->stream;
1271 1271
     MpegTSFilter *tss;
1272
-    int len, pid, cc, cc_ok, afc, is_start;
1272
+    int len, pid, cc, expected_cc, cc_ok, afc, is_start;
1273 1273
     const uint8_t *p, *p_end;
1274 1274
     int64_t pos;
1275 1275
 
... ...
@@ -1287,7 +1287,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
1287 1287
 
1288 1288
     /* continuity check (currently not used) */
1289 1289
     cc = (packet[3] & 0xf);
1290
-    cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
1290
+    expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : tss->last_cc;
1291
+    cc_ok = (tss->last_cc < 0) || (expected_cc == cc);
1291 1292
     tss->last_cc = cc;
1292 1293
 
1293 1294
     /* skip adaptation field */
... ...
@@ -118,24 +118,27 @@ double av_evaluate_lls(LLSModel *m, double *param, int order)
118 118
 
119 119
 #ifdef TEST
120 120
 
121
-#include <stdlib.h>
122 121
 #include <stdio.h>
122
+#include <limits.h>
123
+#include "lfg.h"
123 124
 
124 125
 int main(void)
125 126
 {
126 127
     LLSModel m;
127 128
     int i, order;
129
+    AVLFG lfg;
128 130
 
131
+    av_lfg_init(&lfg, 1);
129 132
     av_init_lls(&m, 3);
130 133
 
131 134
     for (i = 0; i < 100; i++) {
132 135
         double var[4];
133 136
         double eval;
134 137
 
135
-        var[0] = (rand() / (double) RAND_MAX - 0.5) * 2;
136
-        var[1] = var[0] + rand() / (double) RAND_MAX - 0.5;
137
-        var[2] = var[1] + rand() / (double) RAND_MAX - 0.5;
138
-        var[3] = var[2] + rand() / (double) RAND_MAX - 0.5;
138
+        var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
139
+        var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
140
+        var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
141
+        var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
139 142
         av_update_lls(&m, var, 0.99);
140 143
         av_solve_lls(&m, 0.001, 0);
141 144
         for (order = 0; order < 3; order++) {
... ...
@@ -35,14 +35,14 @@ install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
35 35
 
36 36
 define RULES
37 37
 $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
38
-	$$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
38
+	$$(LD) $(LDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
39 39
 
40 40
 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
41 41
 	$(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
42 42
 
43 43
 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
44 44
 	$(SLIB_CREATE_DEF_CMD)
45
-	$$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
45
+	$$(LD) $(SHFLAGS) $(LDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
46 46
 	$(SLIB_EXTRA_CMD)
47 47
 
48 48
 ifdef SUBDIR
... ...
@@ -29,7 +29,7 @@ tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
29 29
 tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
30 30
 
31 31
 tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
32
-	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
32
+	$(LD) $(LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
33 33
 
34 34
 include $(SRC_PATH)/tests/fate.mak
35 35
 include $(SRC_PATH)/tests/fate2.mak