42 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
58 int effect_type, effect_flag;
59 int effect_pcount1, effect_pcount2;
60 int effect_params1[15], effect_params2[10];
68 static void vc1_sprite_parse_transform(
GetBitContext* gb,
int c[7])
75 c[2] = get_fp_val(gb);
79 c[0] = c[4] = get_fp_val(gb);
80 c[2] = get_fp_val(gb);
83 c[0] = get_fp_val(gb);
84 c[2] = get_fp_val(gb);
85 c[4] = get_fp_val(gb);
88 c[0] = get_fp_val(gb);
89 c[1] = get_fp_val(gb);
90 c[2] = get_fp_val(gb);
91 c[3] = get_fp_val(gb);
92 c[4] = get_fp_val(gb);
95 c[5] = get_fp_val(gb);
97 c[6] = get_fp_val(gb);
107 for (sprite = 0; sprite <= v->
two_sprites; sprite++) {
108 vc1_sprite_parse_transform(gb, sd->coefs[sprite]);
109 if (sd->coefs[sprite][1] || sd->coefs[sprite][3])
112 for (i = 0; i < 7; i++)
114 sd->coefs[sprite][i] / (1<<16),
115 (abs(sd->coefs[sprite][i]) & 0xFFFF) * 1000 / (1 << 16));
121 switch (sd->effect_pcount1 =
get_bits(gb, 4)) {
123 vc1_sprite_parse_transform(gb, sd->effect_params1);
126 vc1_sprite_parse_transform(gb, sd->effect_params1);
127 vc1_sprite_parse_transform(gb, sd->effect_params1 + 7);
130 for (i = 0; i < sd->effect_pcount1; i++)
131 sd->effect_params1[i] = get_fp_val(gb);
133 if (sd->effect_type != 13 || sd->effect_params1[0] != sd->coefs[0][6]) {
136 for (i = 0; i < sd->effect_pcount1; i++)
138 sd->effect_params1[i] / (1 << 16),
139 (abs(sd->effect_params1[i]) & 0xFFFF) * 1000 / (1 << 16));
143 sd->effect_pcount2 =
get_bits(gb, 16);
144 if (sd->effect_pcount2 > 10) {
147 }
else if (sd->effect_pcount2) {
150 while (++i < sd->effect_pcount2) {
151 sd->effect_params2[i] = get_fp_val(gb);
153 sd->effect_params2[i] / (1 << 16),
154 (abs(sd->effect_params2[i]) & 0xFFFF) * 1000 / (1 << 16));
173 static void vc1_draw_sprites(
VC1Context *v, SpriteData* sd)
175 int i, plane, row, sprite;
176 int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } };
178 int xoff[2], xadv[2], yoff[2], yadv[2],
alpha;
183 xoff[i] = av_clip(sd->coefs[i][2], 0, v->
sprite_width-1 << 16);
184 xadv[i] = sd->coefs[i][0];
188 yoff[i] = av_clip(sd->coefs[i][5], 0, v->
sprite_height-1 << 16);
191 alpha = av_clip(sd->coefs[1][6], 0, (1<<16) - 1);
200 for (sprite = 0; sprite <= v->
two_sprites; sprite++) {
203 int ycoord = yoff[sprite] + yadv[sprite] * row;
204 int yline = ycoord >> 16;
206 ysub[sprite] = ycoord & 0xFFFF;
212 if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) {
213 src_h[sprite][0] = iplane + (xoff[sprite] >> 16) + yline * iline;
215 src_h[sprite][1] = iplane + (xoff[sprite] >> 16) + next_line;
217 if (sr_cache[sprite][0] != yline) {
218 if (sr_cache[sprite][1] == yline) {
220 FFSWAP(
int, sr_cache[sprite][0], sr_cache[sprite][1]);
222 v->
vc1dsp.
sprite_h(v->
sr_rows[sprite][0], iplane + yline * iline, xoff[sprite], xadv[sprite], width);
223 sr_cache[sprite][0] = yline;
226 if (ysub[sprite] && sr_cache[sprite][1] != yline + 1) {
228 iplane + next_line, xoff[sprite],
229 xadv[sprite], width);
230 sr_cache[sprite][1] = yline + 1;
232 src_h[sprite][0] = v->
sr_rows[sprite][0];
233 src_h[sprite][1] = v->
sr_rows[sprite][1];
241 memcpy(dst, src_h[0][0], width);
244 if (ysub[0] && ysub[1]) {
246 src_h[1][0], src_h[1][1], ysub[1], alpha, width);
247 }
else if (ysub[0]) {
249 src_h[1][0], alpha, width);
250 }
else if (ysub[1]) {
252 src_h[0][0], (1<<16)-1-alpha, width);
277 memset(&sd, 0,
sizeof(sd));
279 ret = vc1_parse_sprites(v, gb, &sd);
297 vc1_draw_sprites(v, &sd);
317 plane ? 128 : 0, f->
linesize[plane]);
374 for (i = 0; i < 4; i++)
401 for (i = 0; i < 64; i++) {
402 #define transpose(x) (((x) >> 3) | (((x) & 7) << 3))
469 }
else if (count < 0) {
478 int seq_initialized = 0, ep_initialized = 0;
488 for (; next <
end; start = next) {
490 size = next - start - 4;
513 if (!seq_initialized || !ep_initialized) {
579 for (i = 0; i < 4; i++)
611 int buf_size = avpkt->
size, n_slices = 0, i,
ret;
616 const uint8_t *buf_start =
buf, *buf_start_second_field = NULL;
617 int mb_height, n_slices1=-1;
622 } *slices = NULL, *tmp;
662 for (start = buf, end = buf + buf_size; next <
end; start = next) {
664 size = next - start - 4;
665 if (size <= 0)
continue;
677 buf_start_second_field =
start;
683 if (!slices[n_slices].buf)
686 slices[n_slices].buf);
691 slices[n_slices].mby_start = s->
mb_height + 1 >> 1;
692 n_slices1 = n_slices - 1;
708 if (!slices[n_slices].buf)
711 slices[n_slices].buf);
714 slices[n_slices].mby_start =
get_bits(&slices[n_slices].gb, 9);
720 }
else if (v->
interlace && ((buf[0] & 0xC0) == 0xC0)) {
731 buf_start_second_field = divider;
737 if (!slices[n_slices].buf)
739 buf_size3 =
vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf);
742 slices[n_slices].mby_start = s->
mb_height + 1 >> 1;
743 n_slices1 = n_slices - 1;
869 if ((CONFIG_VC1_VDPAU_DECODER)
871 if (v->
field_mode && buf_start_second_field) {
878 if (v->
field_mode && buf_start_second_field) {
881 if (avctx->
hwaccel->
start_frame(avctx, buf_start, buf_start_second_field - buf_start) < 0)
883 if (avctx->
hwaccel->
decode_slice(avctx, buf_start, buf_start_second_field - buf_start) < 0)
889 s->
gb = slices[n_slices1 + 1].gb;
899 if (avctx->
hwaccel->
start_frame(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
901 if (avctx->
hwaccel->
decode_slice(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
919 v->
bits = buf_size * 8;
932 for (i = 0; i <= n_slices; i++) {
933 if (i > 0 && slices[i - 1].mby_start >= mb_height) {
936 "picture boundary (%d >= %d)\n", i,
937 slices[i - 1].mby_start, mb_height);
970 s->
start_mb_y = (i == 0) ? 0 :
FFMAX(0, slices[i-1].mby_start % mb_height);
972 s->
end_mb_y = (i == n_slices ) ? mb_height :
FFMIN(mb_height, slices[i].mby_start % mb_height);
978 s->
end_mb_y = (i <= n_slices1 + 1) ? mb_height :
FFMIN(mb_height, slices[i].mby_start % mb_height);
990 s->
gb = slices[i].gb;
1022 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
1023 if (vc1_decode_sprites(v, &s->
gb))
1045 for (i = 0; i < n_slices; i++)
1052 for (i = 0; i < n_slices; i++)
1068 #if CONFIG_VC1_DXVA2_HWACCEL
1071 #if CONFIG_VC1_VAAPI_HWACCEL
1074 #if CONFIG_VC1_VDPAU_HWACCEL
1092 .pix_fmts = vc1_hwaccel_pixfmt_list_420,
1096 #if CONFIG_WMV3_DECODER
1108 .pix_fmts = vc1_hwaccel_pixfmt_list_420,
1113 #if CONFIG_WMV3_VDPAU_DECODER
1114 AVCodec ff_wmv3_vdpau_decoder = {
1115 .
name =
"wmv3_vdpau",
1129 #if CONFIG_VC1_VDPAU_DECODER
1130 AVCodec ff_vc1_vdpau_decoder = {
1131 .
name =
"vc1_vdpau",
1145 #if CONFIG_WMV3IMAGE_DECODER
1146 AVCodec ff_wmv3image_decoder = {
1147 .
name =
"wmv3image",
1156 .
flush = vc1_sprite_flush,
1164 #if CONFIG_VC1IMAGE_DECODER
1165 AVCodec ff_vc1image_decoder = {
1175 .
flush = vc1_sprite_flush,