annotate mpegvideo_common.h @ 8533:0533343a4002 libavcodec

Export VDPAU support by installing vdpau.h.
author cehoyos
date Mon, 05 Jan 2009 23:25:58 +0000
parents 50516d28608a
children 7a463923ecd1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
1 /*
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
2 * The simplest mpeg encoder (well, it was the simplest!)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
3 * Copyright (c) 2000,2001 Fabrice Bellard.
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
5 *
5214
470601203f44 Group all copyright and author notices together.
diego
parents: 5204
diff changeset
6 * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at>
470601203f44 Group all copyright and author notices together.
diego
parents: 5204
diff changeset
7 *
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
8 * This file is part of FFmpeg.
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
9 *
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
10 * FFmpeg is free software; you can redistribute it and/or
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
11 * modify it under the terms of the GNU Lesser General Public
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
12 * License as published by the Free Software Foundation; either
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
13 * version 2.1 of the License, or (at your option) any later version.
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
14 *
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
15 * FFmpeg is distributed in the hope that it will be useful,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
18 * Lesser General Public License for more details.
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
19 *
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
20 * You should have received a copy of the GNU Lesser General Public
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
21 * License along with FFmpeg; if not, write to the Free Software
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
23 */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
24
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
25 /**
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
26 * @file mpegvideo_common.h
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
27 * The simplest mpeg encoder (well, it was the simplest!).
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
28 */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
29
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 6659
diff changeset
30 #ifndef AVCODEC_MPEGVIDEO_COMMON_H
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 6659
diff changeset
31 #define AVCODEC_MPEGVIDEO_COMMON_H
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
32
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
33 #include "avcodec.h"
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
34 #include "dsputil.h"
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
35 #include "mpegvideo.h"
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
36 #include "mjpegenc.h"
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
37 #include "msmpeg4.h"
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
38 #include "faandct.h"
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
39 #include <limits.h>
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
40
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
41 int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
42 int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
43 void denoise_dct_c(MpegEncContext *s, DCTELEM *block);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
44
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
45 /**
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
46 * allocates a Picture
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
47 * The pixels are allocated/set by calling get_buffer() if shared=0
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
48 */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
49 int alloc_picture(MpegEncContext *s, Picture *pic, int shared);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
50
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
51 /**
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
52 * sets the given MpegEncContext to common defaults (same for encoding and decoding).
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
53 * the changed fields will not depend upon the prior state of the MpegEncContext.
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
54 */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
55 void MPV_common_defaults(MpegEncContext *s);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
56
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
57 static inline void gmc1_motion(MpegEncContext *s,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
58 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
59 uint8_t **ref_picture)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
60 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
61 uint8_t *ptr;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
62 int offset, src_x, src_y, linesize, uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
63 int motion_x, motion_y;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
64 int emu=0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
65
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
66 motion_x= s->sprite_offset[0][0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
67 motion_y= s->sprite_offset[0][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
68 src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy+1));
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
69 src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy+1));
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
70 motion_x<<=(3-s->sprite_warping_accuracy);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
71 motion_y<<=(3-s->sprite_warping_accuracy);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
72 src_x = av_clip(src_x, -16, s->width);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
73 if (src_x == s->width)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
74 motion_x =0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
75 src_y = av_clip(src_y, -16, s->height);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
76 if (src_y == s->height)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
77 motion_y =0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
78
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
79 linesize = s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
80 uvlinesize = s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
81
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
82 ptr = ref_picture[0] + (src_y * linesize) + src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
83
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
84 if(s->flags&CODEC_FLAG_EMU_EDGE){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
85 if( (unsigned)src_x >= s->h_edge_pos - 17
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
86 || (unsigned)src_y >= s->v_edge_pos - 17){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
87 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
88 ptr= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
89 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
90 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
91
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
92 if((motion_x|motion_y)&7){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
93 s->dsp.gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
94 s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
95 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
96 int dxy;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
97
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
98 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
99 if (s->no_rounding){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
100 s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
101 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
102 s->dsp.put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
103 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
104 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
105
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
106 if(ENABLE_GRAY && s->flags&CODEC_FLAG_GRAY) return;
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
107
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
108 motion_x= s->sprite_offset[1][0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
109 motion_y= s->sprite_offset[1][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
110 src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy+1));
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
111 src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy+1));
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
112 motion_x<<=(3-s->sprite_warping_accuracy);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
113 motion_y<<=(3-s->sprite_warping_accuracy);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
114 src_x = av_clip(src_x, -8, s->width>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
115 if (src_x == s->width>>1)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
116 motion_x =0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
117 src_y = av_clip(src_y, -8, s->height>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
118 if (src_y == s->height>>1)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
119 motion_y =0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
120
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
121 offset = (src_y * uvlinesize) + src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
122 ptr = ref_picture[1] + offset;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
123 if(s->flags&CODEC_FLAG_EMU_EDGE){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
124 if( (unsigned)src_x >= (s->h_edge_pos>>1) - 9
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
125 || (unsigned)src_y >= (s->v_edge_pos>>1) - 9){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
126 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
127 ptr= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
128 emu=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
129 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
130 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
131 s->dsp.gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
132
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
133 ptr = ref_picture[2] + offset;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
134 if(emu){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
135 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
136 ptr= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
137 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
138 s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
139
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
140 return;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
141 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
142
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
143 static inline void gmc_motion(MpegEncContext *s,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
144 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
145 uint8_t **ref_picture)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
146 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
147 uint8_t *ptr;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
148 int linesize, uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
149 const int a= s->sprite_warping_accuracy;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
150 int ox, oy;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
151
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
152 linesize = s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
153 uvlinesize = s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
154
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
155 ptr = ref_picture[0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
156
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
157 ox= s->sprite_offset[0][0] + s->sprite_delta[0][0]*s->mb_x*16 + s->sprite_delta[0][1]*s->mb_y*16;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
158 oy= s->sprite_offset[0][1] + s->sprite_delta[1][0]*s->mb_x*16 + s->sprite_delta[1][1]*s->mb_y*16;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
159
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
160 s->dsp.gmc(dest_y, ptr, linesize, 16,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
161 ox,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
162 oy,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
163 s->sprite_delta[0][0], s->sprite_delta[0][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
164 s->sprite_delta[1][0], s->sprite_delta[1][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
165 a+1, (1<<(2*a+1)) - s->no_rounding,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
166 s->h_edge_pos, s->v_edge_pos);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
167 s->dsp.gmc(dest_y+8, ptr, linesize, 16,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
168 ox + s->sprite_delta[0][0]*8,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
169 oy + s->sprite_delta[1][0]*8,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
170 s->sprite_delta[0][0], s->sprite_delta[0][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
171 s->sprite_delta[1][0], s->sprite_delta[1][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
172 a+1, (1<<(2*a+1)) - s->no_rounding,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
173 s->h_edge_pos, s->v_edge_pos);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
174
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
175 if(ENABLE_GRAY && s->flags&CODEC_FLAG_GRAY) return;
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
176
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
177 ox= s->sprite_offset[1][0] + s->sprite_delta[0][0]*s->mb_x*8 + s->sprite_delta[0][1]*s->mb_y*8;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
178 oy= s->sprite_offset[1][1] + s->sprite_delta[1][0]*s->mb_x*8 + s->sprite_delta[1][1]*s->mb_y*8;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
179
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
180 ptr = ref_picture[1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
181 s->dsp.gmc(dest_cb, ptr, uvlinesize, 8,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
182 ox,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
183 oy,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
184 s->sprite_delta[0][0], s->sprite_delta[0][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
185 s->sprite_delta[1][0], s->sprite_delta[1][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
186 a+1, (1<<(2*a+1)) - s->no_rounding,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
187 s->h_edge_pos>>1, s->v_edge_pos>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
188
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
189 ptr = ref_picture[2];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
190 s->dsp.gmc(dest_cr, ptr, uvlinesize, 8,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
191 ox,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
192 oy,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
193 s->sprite_delta[0][0], s->sprite_delta[0][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
194 s->sprite_delta[1][0], s->sprite_delta[1][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
195 a+1, (1<<(2*a+1)) - s->no_rounding,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
196 s->h_edge_pos>>1, s->v_edge_pos>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
197 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
198
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
199 static inline int hpel_motion(MpegEncContext *s,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
200 uint8_t *dest, uint8_t *src,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
201 int field_based, int field_select,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
202 int src_x, int src_y,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
203 int width, int height, int stride,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
204 int h_edge_pos, int v_edge_pos,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
205 int w, int h, op_pixels_func *pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
206 int motion_x, int motion_y)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
207 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
208 int dxy;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
209 int emu=0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
210
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
211 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
212 src_x += motion_x >> 1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
213 src_y += motion_y >> 1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
214
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
215 /* WARNING: do no forget half pels */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
216 src_x = av_clip(src_x, -16, width); //FIXME unneeded for emu?
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
217 if (src_x == width)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
218 dxy &= ~1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
219 src_y = av_clip(src_y, -16, height);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
220 if (src_y == height)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
221 dxy &= ~2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
222 src += src_y * stride + src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
223
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
224 if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
225 if( (unsigned)src_x > h_edge_pos - (motion_x&1) - w
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
226 || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
227 ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
228 src_x, src_y<<field_based, h_edge_pos, s->v_edge_pos);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
229 src= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
230 emu=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
231 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
232 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
233 if(field_select)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
234 src += s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
235 pix_op[dxy](dest, src, stride, h);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
236 return emu;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
237 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
238
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
239 static av_always_inline
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
240 void mpeg_motion_internal(MpegEncContext *s,
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
241 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
242 int field_based, int bottom_field, int field_select,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
243 uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
244 int motion_x, int motion_y, int h, int is_mpeg12)
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
245 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
246 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
247 int dxy, uvdxy, mx, my, src_x, src_y,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
248 uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize;
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
249
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
250 #if 0
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
251 if(s->quarter_sample)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
252 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
253 motion_x>>=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
254 motion_y>>=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
255 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
256 #endif
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
257
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
258 v_edge_pos = s->v_edge_pos >> field_based;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
259 linesize = s->current_picture.linesize[0] << field_based;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
260 uvlinesize = s->current_picture.linesize[1] << field_based;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
261
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
262 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
263 src_x = s->mb_x* 16 + (motion_x >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
264 src_y =(s->mb_y<<(4-field_based)) + (motion_y >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
265
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
266 if (!is_mpeg12 && s->out_format == FMT_H263) {
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
267 if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
268 mx = (motion_x>>1)|(motion_x&1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
269 my = motion_y >>1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
270 uvdxy = ((my & 1) << 1) | (mx & 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
271 uvsrc_x = s->mb_x* 8 + (mx >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
272 uvsrc_y = (s->mb_y<<(3-field_based)) + (my >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
273 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
274 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
275 uvsrc_x = src_x>>1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
276 uvsrc_y = src_y>>1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
277 }
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
278 }else if(!is_mpeg12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
279 mx = motion_x / 4;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
280 my = motion_y / 4;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
281 uvdxy = 0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
282 uvsrc_x = s->mb_x*8 + mx;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
283 uvsrc_y = s->mb_y*8 + my;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
284 } else {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
285 if(s->chroma_y_shift){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
286 mx = motion_x / 2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
287 my = motion_y / 2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
288 uvdxy = ((my & 1) << 1) | (mx & 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
289 uvsrc_x = s->mb_x* 8 + (mx >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
290 uvsrc_y = (s->mb_y<<(3-field_based)) + (my >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
291 } else {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
292 if(s->chroma_x_shift){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
293 //Chroma422
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
294 mx = motion_x / 2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
295 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
296 uvsrc_x = s->mb_x* 8 + (mx >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
297 uvsrc_y = src_y;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
298 } else {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
299 //Chroma444
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
300 uvdxy = dxy;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
301 uvsrc_x = src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
302 uvsrc_y = src_y;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
303 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
304 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
305 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
306
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
307 ptr_y = ref_picture[0] + src_y * linesize + src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
308 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
309 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
310
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
311 if( (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 16
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
312 || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
313 if(is_mpeg12 || s->codec_id == CODEC_ID_MPEG2VIDEO ||
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
314 s->codec_id == CODEC_ID_MPEG1VIDEO){
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
315 av_log(s->avctx,AV_LOG_DEBUG,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
316 "MPEG motion vector out of boundary\n");
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
317 return ;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
318 }
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
319 ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
320 17, 17+field_based,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
321 src_x, src_y<<field_based,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
322 s->h_edge_pos, s->v_edge_pos);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
323 ptr_y = s->edge_emu_buffer;
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
324 if(!ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
325 uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
326 ff_emulated_edge_mc(uvbuf ,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
327 ptr_cb, s->uvlinesize,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
328 9, 9+field_based,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
329 uvsrc_x, uvsrc_y<<field_based,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
330 s->h_edge_pos>>1, s->v_edge_pos>>1);
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
331 ff_emulated_edge_mc(uvbuf+16,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
332 ptr_cr, s->uvlinesize,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
333 9, 9+field_based,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
334 uvsrc_x, uvsrc_y<<field_based,
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
335 s->h_edge_pos>>1, s->v_edge_pos>>1);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
336 ptr_cb= uvbuf;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
337 ptr_cr= uvbuf+16;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
338 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
339 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
340
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
341 if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
342 dest_y += s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
343 dest_cb+= s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
344 dest_cr+= s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
345 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
346
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
347 if(field_select){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
348 ptr_y += s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
349 ptr_cb+= s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
350 ptr_cr+= s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
351 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
352
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
353 pix_op[0][dxy](dest_y, ptr_y, linesize, h);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
354
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
355 if(!ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
356 pix_op[s->chroma_x_shift][uvdxy]
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
357 (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
358 pix_op[s->chroma_x_shift][uvdxy]
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
359 (dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
360 }
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
361 if(!is_mpeg12 && (ENABLE_H261_ENCODER || ENABLE_H261_DECODER) &&
6578
dfa423a2fc78 cosmetics: Break some overly long lines.
diego
parents: 6481
diff changeset
362 s->out_format == FMT_H261){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
363 ff_h261_loop_filter(s);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
364 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
365 }
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
366 /* apply one mpeg motion vector to the three components */
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
367 static av_always_inline
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
368 void mpeg_motion(MpegEncContext *s,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
369 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
370 int field_based, int bottom_field, int field_select,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
371 uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
372 int motion_x, int motion_y, int h)
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
373 {
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
374 #ifndef CONFIG_SMALL
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
375 if(s->out_format == FMT_MPEG1)
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
376 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
377 bottom_field, field_select, ref_picture, pix_op,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
378 motion_x, motion_y, h, 1);
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
379 else
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
380 #endif
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
381 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
382 bottom_field, field_select, ref_picture, pix_op,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
383 motion_x, motion_y, h, 0);
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
384 }
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
385
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
386 //FIXME move to dsputil, avg variant, 16x16 version
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
387 static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
388 int x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
389 uint8_t * const top = src[1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
390 uint8_t * const left = src[2];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
391 uint8_t * const mid = src[0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
392 uint8_t * const right = src[3];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
393 uint8_t * const bottom= src[4];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
394 #define OBMC_FILTER(x, t, l, m, r, b)\
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
395 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
396 #define OBMC_FILTER4(x, t, l, m, r, b)\
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
397 OBMC_FILTER(x , t, l, m, r, b);\
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
398 OBMC_FILTER(x+1 , t, l, m, r, b);\
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
399 OBMC_FILTER(x +stride, t, l, m, r, b);\
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
400 OBMC_FILTER(x+1+stride, t, l, m, r, b);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
401
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
402 x=0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
403 OBMC_FILTER (x , 2, 2, 4, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
404 OBMC_FILTER (x+1, 2, 1, 5, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
405 OBMC_FILTER4(x+2, 2, 1, 5, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
406 OBMC_FILTER4(x+4, 2, 0, 5, 1, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
407 OBMC_FILTER (x+6, 2, 0, 5, 1, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
408 OBMC_FILTER (x+7, 2, 0, 4, 2, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
409 x+= stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
410 OBMC_FILTER (x , 1, 2, 5, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
411 OBMC_FILTER (x+1, 1, 2, 5, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
412 OBMC_FILTER (x+6, 1, 0, 5, 2, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
413 OBMC_FILTER (x+7, 1, 0, 5, 2, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
414 x+= stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
415 OBMC_FILTER4(x , 1, 2, 5, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
416 OBMC_FILTER4(x+2, 1, 1, 6, 0, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
417 OBMC_FILTER4(x+4, 1, 0, 6, 1, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
418 OBMC_FILTER4(x+6, 1, 0, 5, 2, 0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
419 x+= 2*stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
420 OBMC_FILTER4(x , 0, 2, 5, 0, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
421 OBMC_FILTER4(x+2, 0, 1, 6, 0, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
422 OBMC_FILTER4(x+4, 0, 0, 6, 1, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
423 OBMC_FILTER4(x+6, 0, 0, 5, 2, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
424 x+= 2*stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
425 OBMC_FILTER (x , 0, 2, 5, 0, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
426 OBMC_FILTER (x+1, 0, 2, 5, 0, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
427 OBMC_FILTER4(x+2, 0, 1, 5, 0, 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
428 OBMC_FILTER4(x+4, 0, 0, 5, 1, 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
429 OBMC_FILTER (x+6, 0, 0, 5, 2, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
430 OBMC_FILTER (x+7, 0, 0, 5, 2, 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
431 x+= stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
432 OBMC_FILTER (x , 0, 2, 4, 0, 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
433 OBMC_FILTER (x+1, 0, 1, 5, 0, 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
434 OBMC_FILTER (x+6, 0, 0, 5, 1, 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
435 OBMC_FILTER (x+7, 0, 0, 4, 2, 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
436 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
437
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
438 /* obmc for 1 8x8 luma block */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
439 static inline void obmc_motion(MpegEncContext *s,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
440 uint8_t *dest, uint8_t *src,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
441 int src_x, int src_y,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
442 op_pixels_func *pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
443 int16_t mv[5][2]/* mid top left right bottom*/)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
444 #define MID 0
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
445 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
446 int i;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
447 uint8_t *ptr[5];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
448
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
449 assert(s->quarter_sample==0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
450
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
451 for(i=0; i<5; i++){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
452 if(i && mv[i][0]==mv[MID][0] && mv[i][1]==mv[MID][1]){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
453 ptr[i]= ptr[MID];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
454 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
455 ptr[i]= s->obmc_scratchpad + 8*(i&1) + s->linesize*8*(i>>1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
456 hpel_motion(s, ptr[i], src, 0, 0,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
457 src_x, src_y,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
458 s->width, s->height, s->linesize,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
459 s->h_edge_pos, s->v_edge_pos,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
460 8, 8, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
461 mv[i][0], mv[i][1]);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
462 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
463 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
464
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
465 put_obmc(dest, ptr, s->linesize);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
466 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
467
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
468 static inline void qpel_motion(MpegEncContext *s,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
469 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
470 int field_based, int bottom_field, int field_select,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
471 uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
472 qpel_mc_func (*qpix_op)[16],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
473 int motion_x, int motion_y, int h)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
474 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
475 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
476 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, linesize, uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
477
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
478 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
479 src_x = s->mb_x * 16 + (motion_x >> 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
480 src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
481
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
482 v_edge_pos = s->v_edge_pos >> field_based;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
483 linesize = s->linesize << field_based;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
484 uvlinesize = s->uvlinesize << field_based;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
485
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
486 if(field_based){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
487 mx= motion_x/2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
488 my= motion_y>>1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
489 }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA2){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
490 static const int rtab[8]= {0,0,1,1,0,0,0,1};
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
491 mx= (motion_x>>1) + rtab[motion_x&7];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
492 my= (motion_y>>1) + rtab[motion_y&7];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
493 }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
494 mx= (motion_x>>1)|(motion_x&1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
495 my= (motion_y>>1)|(motion_y&1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
496 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
497 mx= motion_x/2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
498 my= motion_y/2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
499 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
500 mx= (mx>>1)|(mx&1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
501 my= (my>>1)|(my&1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
502
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
503 uvdxy= (mx&1) | ((my&1)<<1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
504 mx>>=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
505 my>>=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
506
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
507 uvsrc_x = s->mb_x * 8 + mx;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
508 uvsrc_y = s->mb_y * (8 >> field_based) + my;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
509
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
510 ptr_y = ref_picture[0] + src_y * linesize + src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
511 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
512 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
513
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
514 if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 16
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
515 || (unsigned)src_y > v_edge_pos - (motion_y&3) - h ){
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
516 ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
517 17, 17+field_based, src_x, src_y<<field_based,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
518 s->h_edge_pos, s->v_edge_pos);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
519 ptr_y= s->edge_emu_buffer;
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
520 if(!ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
521 uint8_t *uvbuf= s->edge_emu_buffer + 18*s->linesize;
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
522 ff_emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
523 9, 9 + field_based,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
524 uvsrc_x, uvsrc_y<<field_based,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
525 s->h_edge_pos>>1, s->v_edge_pos>>1);
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
526 ff_emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
527 9, 9 + field_based,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
528 uvsrc_x, uvsrc_y<<field_based,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
529 s->h_edge_pos>>1, s->v_edge_pos>>1);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
530 ptr_cb= uvbuf;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
531 ptr_cr= uvbuf + 16;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
532 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
533 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
534
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
535 if(!field_based)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
536 qpix_op[0][dxy](dest_y, ptr_y, linesize);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
537 else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
538 if(bottom_field){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
539 dest_y += s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
540 dest_cb+= s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
541 dest_cr+= s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
542 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
543
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
544 if(field_select){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
545 ptr_y += s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
546 ptr_cb += s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
547 ptr_cr += s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
548 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
549 //damn interlaced mode
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
550 //FIXME boundary mirroring is not exactly correct here
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
551 qpix_op[1][dxy](dest_y , ptr_y , linesize);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
552 qpix_op[1][dxy](dest_y+8, ptr_y+8, linesize);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
553 }
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
554 if(!ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
555 pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
556 pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
557 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
558 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
559
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
560 /**
5428
750d76a34871 Fix typo
takis
parents: 5214
diff changeset
561 * h263 chroma 4mv motion compensation.
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
562 */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
563 static inline void chroma_4mv_motion(MpegEncContext *s,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
564 uint8_t *dest_cb, uint8_t *dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
565 uint8_t **ref_picture,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
566 op_pixels_func *pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
567 int mx, int my){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
568 int dxy, emu=0, src_x, src_y, offset;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
569 uint8_t *ptr;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
570
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
571 /* In case of 8X8, we construct a single chroma motion vector
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
572 with a special rounding */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
573 mx= ff_h263_round_chroma(mx);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
574 my= ff_h263_round_chroma(my);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
575
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
576 dxy = ((my & 1) << 1) | (mx & 1);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
577 mx >>= 1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
578 my >>= 1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
579
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
580 src_x = s->mb_x * 8 + mx;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
581 src_y = s->mb_y * 8 + my;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
582 src_x = av_clip(src_x, -8, s->width/2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
583 if (src_x == s->width/2)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
584 dxy &= ~1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
585 src_y = av_clip(src_y, -8, s->height/2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
586 if (src_y == s->height/2)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
587 dxy &= ~2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
588
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
589 offset = (src_y * (s->uvlinesize)) + src_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
590 ptr = ref_picture[1] + offset;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
591 if(s->flags&CODEC_FLAG_EMU_EDGE){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
592 if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
593 || (unsigned)src_y > (s->v_edge_pos>>1) - (dxy>>1) - 8){
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
594 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
595 9, 9, src_x, src_y,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
596 s->h_edge_pos>>1, s->v_edge_pos>>1);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
597 ptr= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
598 emu=1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
599 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
600 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
601 pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
602
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
603 ptr = ref_picture[2] + offset;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
604 if(emu){
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
605 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
606 9, 9, src_x, src_y,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
607 s->h_edge_pos>>1, s->v_edge_pos>>1);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
608 ptr= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
609 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
610 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
611 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
612
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
613 static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
614 /* fetch pixels for estimated mv 4 macroblocks ahead
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
615 * optimized for 64byte cache lines */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
616 const int shift = s->quarter_sample ? 2 : 1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
617 const int mx= (s->mv[dir][0][0]>>shift) + 16*s->mb_x + 8;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
618 const int my= (s->mv[dir][0][1]>>shift) + 16*s->mb_y;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
619 int off= mx + (my + (s->mb_x&3)*4)*s->linesize + 64;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
620 s->dsp.prefetch(pix[0]+off, s->linesize, 4);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
621 off= (mx>>1) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + 64;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
622 s->dsp.prefetch(pix[1]+off, pix[2]-pix[1], 2);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
623 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
624
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
625 /**
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
626 * motion compensation of a single macroblock
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
627 * @param s context
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
628 * @param dest_y luma destination pointer
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
629 * @param dest_cb chroma cb/u destination pointer
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
630 * @param dest_cr chroma cr/v destination pointer
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
631 * @param dir direction (0->forward, 1->backward)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
632 * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
633 * @param pic_op halfpel motion compensation function (average or put normally)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
634 * @param pic_op qpel motion compensation function (average or put normally)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
635 * the motion vectors are taken from s->mv and the MV type from s->mv_type
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
636 */
6659
4866b892ecbe Force inlining of MPV_motion_internal.
benoit
parents: 6658
diff changeset
637 static av_always_inline void MPV_motion_internal(MpegEncContext *s,
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
638 uint8_t *dest_y, uint8_t *dest_cb,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
639 uint8_t *dest_cr, int dir,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
640 uint8_t **ref_picture,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
641 op_pixels_func (*pix_op)[4],
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
642 qpel_mc_func (*qpix_op)[16], int is_mpeg12)
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
643 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
644 int dxy, mx, my, src_x, src_y, motion_x, motion_y;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
645 int mb_x, mb_y, i;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
646 uint8_t *ptr, *dest;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
647
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
648 mb_x = s->mb_x;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
649 mb_y = s->mb_y;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
650
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
651 prefetch_motion(s, ref_picture, dir);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
652
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
653 if(!is_mpeg12 && s->obmc && s->pict_type != FF_B_TYPE){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
654 int16_t mv_cache[4][4][2];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
655 const int xy= s->mb_x + s->mb_y*s->mb_stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
656 const int mot_stride= s->b8_stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
657 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
658
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
659 assert(!s->mb_skipped);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
660
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
661 memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy ], sizeof(int16_t)*4);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
662 memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
663 memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
664
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
665 if(mb_y==0 || IS_INTRA(s->current_picture.mb_type[xy-s->mb_stride])){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
666 memcpy(mv_cache[0][1], mv_cache[1][1], sizeof(int16_t)*4);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
667 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
668 memcpy(mv_cache[0][1], s->current_picture.motion_val[0][mot_xy-mot_stride], sizeof(int16_t)*4);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
669 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
670
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
671 if(mb_x==0 || IS_INTRA(s->current_picture.mb_type[xy-1])){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
672 *(int32_t*)mv_cache[1][0]= *(int32_t*)mv_cache[1][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
673 *(int32_t*)mv_cache[2][0]= *(int32_t*)mv_cache[2][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
674 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
675 *(int32_t*)mv_cache[1][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
676 *(int32_t*)mv_cache[2][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1+mot_stride];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
677 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
678
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
679 if(mb_x+1>=s->mb_width || IS_INTRA(s->current_picture.mb_type[xy+1])){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
680 *(int32_t*)mv_cache[1][3]= *(int32_t*)mv_cache[1][2];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
681 *(int32_t*)mv_cache[2][3]= *(int32_t*)mv_cache[2][2];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
682 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
683 *(int32_t*)mv_cache[1][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
684 *(int32_t*)mv_cache[2][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2+mot_stride];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
685 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
686
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
687 mx = 0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
688 my = 0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
689 for(i=0;i<4;i++) {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
690 const int x= (i&1)+1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
691 const int y= (i>>1)+1;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
692 int16_t mv[5][2]= {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
693 {mv_cache[y][x ][0], mv_cache[y][x ][1]},
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
694 {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
695 {mv_cache[y][x-1][0], mv_cache[y][x-1][1]},
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
696 {mv_cache[y][x+1][0], mv_cache[y][x+1][1]},
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
697 {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
698 //FIXME cleanup
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
699 obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
700 ref_picture[0],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
701 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
702 pix_op[1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
703 mv);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
704
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
705 mx += mv[0][0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
706 my += mv[0][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
707 }
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
708 if(!ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY))
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
709 chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
710
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
711 return;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
712 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
713
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
714 switch(s->mv_type) {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
715 case MV_TYPE_16X16:
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
716 if(s->mcsel){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
717 if(s->real_sprite_warping_points==1){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
718 gmc1_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
719 ref_picture);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
720 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
721 gmc_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
722 ref_picture);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
723 }
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
724 }else if(!is_mpeg12 && s->quarter_sample){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
725 qpel_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
726 0, 0, 0,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
727 ref_picture, pix_op, qpix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
728 s->mv[dir][0][0], s->mv[dir][0][1], 16);
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
729 }else if(!is_mpeg12 && ENABLE_WMV2 && s->mspel){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
730 ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
731 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
732 s->mv[dir][0][0], s->mv[dir][0][1], 16);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
733 }else
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
734 {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
735 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
736 0, 0, 0,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
737 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
738 s->mv[dir][0][0], s->mv[dir][0][1], 16);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
739 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
740 break;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
741 case MV_TYPE_8X8:
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
742 if (!is_mpeg12) {
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
743 mx = 0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
744 my = 0;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
745 if(s->quarter_sample){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
746 for(i=0;i<4;i++) {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
747 motion_x = s->mv[dir][i][0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
748 motion_y = s->mv[dir][i][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
749
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
750 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
751 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
752 src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
753
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
754 /* WARNING: do no forget half pels */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
755 src_x = av_clip(src_x, -16, s->width);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
756 if (src_x == s->width)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
757 dxy &= ~3;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
758 src_y = av_clip(src_y, -16, s->height);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
759 if (src_y == s->height)
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
760 dxy &= ~12;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
761
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
762 ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
763 if(s->flags&CODEC_FLAG_EMU_EDGE){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
764 if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 8
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
765 || (unsigned)src_y > s->v_edge_pos - (motion_y&3) - 8 ){
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
766 ff_emulated_edge_mc(s->edge_emu_buffer, ptr,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
767 s->linesize, 9, 9,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
768 src_x, src_y,
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
769 s->h_edge_pos, s->v_edge_pos);
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
770 ptr= s->edge_emu_buffer;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
771 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
772 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
773 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
774 qpix_op[1][dxy](dest, ptr, s->linesize);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
775
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
776 mx += s->mv[dir][i][0]/2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
777 my += s->mv[dir][i][1]/2;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
778 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
779 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
780 for(i=0;i<4;i++) {
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
781 hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
782 ref_picture[0], 0, 0,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
783 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
784 s->width, s->height, s->linesize,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
785 s->h_edge_pos, s->v_edge_pos,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
786 8, 8, pix_op[1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
787 s->mv[dir][i][0], s->mv[dir][i][1]);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
788
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
789 mx += s->mv[dir][i][0];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
790 my += s->mv[dir][i][1];
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
791 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
792 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
793
5433
ce0db8111f94 make grayscale only decoding checks in inner loops compiletime killable
michael
parents: 5428
diff changeset
794 if(!ENABLE_GRAY || !(s->flags&CODEC_FLAG_GRAY))
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
795 chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
796 }
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
797 break;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
798 case MV_TYPE_FIELD:
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
799 if (s->picture_structure == PICT_FRAME) {
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
800 if(!is_mpeg12 && s->quarter_sample){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
801 for(i=0; i<2; i++){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
802 qpel_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
803 1, i, s->field_select[dir][i],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
804 ref_picture, pix_op, qpix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
805 s->mv[dir][i][0], s->mv[dir][i][1], 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
806 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
807 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
808 /* top field */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
809 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
810 1, 0, s->field_select[dir][0],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
811 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
812 s->mv[dir][0][0], s->mv[dir][0][1], 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
813 /* bottom field */
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
814 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
815 1, 1, s->field_select[dir][1],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
816 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
817 s->mv[dir][1][0], s->mv[dir][1][1], 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
818 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
819 } else {
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 5830
diff changeset
820 if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != FF_B_TYPE && !s->first_field){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
821 ref_picture= s->current_picture_ptr->data;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
822 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
823
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
824 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
825 0, 0, s->field_select[dir][0],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
826 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
827 s->mv[dir][0][0], s->mv[dir][0][1], 16);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
828 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
829 break;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
830 case MV_TYPE_16X8:
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
831 for(i=0; i<2; i++){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
832 uint8_t ** ref2picture;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
833
6579
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
834 if(s->picture_structure == s->field_select[dir][i] + 1
bd5c42ff9e27 cosmetics: Break some overly long lines.
diego
parents: 6578
diff changeset
835 || s->pict_type == FF_B_TYPE || s->first_field){
5204
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
836 ref2picture= ref_picture;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
837 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
838 ref2picture= s->current_picture_ptr->data;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
839 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
840
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
841 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
842 0, 0, s->field_select[dir][i],
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
843 ref2picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
844 s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
845
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
846 dest_y += 16*s->linesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
847 dest_cb+= (16>>s->chroma_y_shift)*s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
848 dest_cr+= (16>>s->chroma_y_shift)*s->uvlinesize;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
849 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
850 break;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
851 case MV_TYPE_DMV:
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
852 if(s->picture_structure == PICT_FRAME){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
853 for(i=0; i<2; i++){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
854 int j;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
855 for(j=0; j<2; j++){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
856 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
857 1, j, j^i,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
858 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
859 s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
860 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
861 pix_op = s->dsp.avg_pixels_tab;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
862 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
863 }else{
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
864 for(i=0; i<2; i++){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
865 mpeg_motion(s, dest_y, dest_cb, dest_cr,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
866 0, 0, s->picture_structure != i+1,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
867 ref_picture, pix_op,
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
868 s->mv[dir][2*i][0],s->mv[dir][2*i][1],16);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
869
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
870 // after put we make avg of the same block
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
871 pix_op=s->dsp.avg_pixels_tab;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
872
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
873 //opposite parity is always in the same frame if this is second field
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
874 if(!s->first_field){
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
875 ref_picture = s->current_picture_ptr->data;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
876 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
877 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
878 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
879 break;
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
880 default: assert(0);
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
881 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
882 }
1c3baf4323bb Description: split mpegvideo.c
benoit
parents:
diff changeset
883
6658
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
884 static inline void MPV_motion(MpegEncContext *s,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
885 uint8_t *dest_y, uint8_t *dest_cb,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
886 uint8_t *dest_cr, int dir,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
887 uint8_t **ref_picture,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
888 op_pixels_func (*pix_op)[4],
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
889 qpel_mc_func (*qpix_op)[16])
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
890 {
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
891 #ifndef CONFIG_SMALL
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
892 if(s->out_format == FMT_MPEG1)
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
893 MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
894 ref_picture, pix_op, qpix_op, 1);
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
895 else
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
896 #endif
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
897 MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
898 ref_picture, pix_op, qpix_op, 0);
7ecd59aa5757 Unroll codepath
benoit
parents: 6579
diff changeset
899 }
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 6659
diff changeset
900 #endif /* AVCODEC_MPEGVIDEO_COMMON_H */