annotate mpegvideo_common.h @ 6637:0557f6cc5ed0 libavcodec

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