Changeset 28c10c83b4dc8f1de74a1180d68b44a04a6458d4
- Timestamp:
- 08/03/05 14:16:38
(4 years ago)
- Author:
- Gildas Bazin <gbazin@videolan.org>
- git-committer:
- Gildas Bazin <gbazin@videolan.org> 1110287798 +0000
- git-parent:
[739d192acea9e963c567f006b477ec278070d3d5]
- git-author:
- Gildas Bazin <gbazin@videolan.org> 1110287798 +0000
- Message:
* modules/codec/ffmpeg/video_filter.c: a few fixes and cleanup.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rae42e9e |
r28c10c8 |
|
| 51 | 51 | vlc_bool_t b_resize; |
|---|
| 52 | 52 | vlc_bool_t b_convert; |
|---|
| | 53 | vlc_bool_t b_resize_first; |
|---|
| 53 | 54 | |
|---|
| 54 | 55 | es_format_t fmt_in; |
|---|
| … | … | |
| 99 | 100 | /* Misc init */ |
|---|
| 100 | 101 | p_sys->p_rsc = NULL; |
|---|
| 101 | | p_sys->b_convert = b_convert; |
|---|
| 102 | 102 | p_sys->i_src_ffmpeg_chroma = |
|---|
| 103 | 103 | E_(GetFfmpegChroma)( p_filter->fmt_in.video.i_chroma ); |
|---|
| … | … | |
| 108 | 108 | es_format_Init( &p_sys->fmt_out, 0, 0 ); |
|---|
| 109 | 109 | |
|---|
| | 110 | /* Dummy alloc, will be reallocated in CheckInit */ |
|---|
| | 111 | avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma, |
|---|
| | 112 | p_filter->fmt_out.video.i_width, |
|---|
| | 113 | p_filter->fmt_out.video.i_height ); |
|---|
| | 114 | |
|---|
| 110 | 115 | if( CheckInit( p_filter ) != VLC_SUCCESS ) |
|---|
| 111 | 116 | { |
|---|
| 112 | 117 | free( p_sys ); |
|---|
| 113 | 118 | return VLC_EGENERIC; |
|---|
| 114 | | } |
|---|
| 115 | | |
|---|
| 116 | | if( p_sys->b_resize && p_sys->b_convert ) |
|---|
| 117 | | { |
|---|
| 118 | | if ( p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > |
|---|
| 119 | | p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height ) |
|---|
| 120 | | { |
|---|
| 121 | | /* Resizing then conversion */ |
|---|
| 122 | | avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma, |
|---|
| 123 | | p_filter->fmt_out.video.i_width, |
|---|
| 124 | | p_filter->fmt_out.video.i_height ); |
|---|
| 125 | | } |
|---|
| 126 | | else |
|---|
| 127 | | { |
|---|
| 128 | | /* Conversion then resizing */ |
|---|
| 129 | | avpicture_alloc( &p_sys->tmp_pic, p_sys->i_dst_ffmpeg_chroma, |
|---|
| 130 | | p_filter->fmt_in.video.i_width, |
|---|
| 131 | | p_filter->fmt_in.video.i_height ); |
|---|
| 132 | | } |
|---|
| 133 | 119 | } |
|---|
| 134 | 120 | |
|---|
| … | … | |
| 175 | 161 | p_sys->p_rsc = 0; |
|---|
| 176 | 162 | |
|---|
| | 163 | p_sys->b_convert = |
|---|
| | 164 | p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma; |
|---|
| | 165 | |
|---|
| 177 | 166 | p_sys->b_resize = |
|---|
| 178 | 167 | p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width || |
|---|
| 179 | 168 | p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height; |
|---|
| | 169 | |
|---|
| | 170 | p_sys->b_resize_first = |
|---|
| | 171 | p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > |
|---|
| | 172 | p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height; |
|---|
| | 173 | |
|---|
| | 174 | if( E_(GetFfmpegChroma)( p_filter->fmt_in.video.i_chroma ) != |
|---|
| | 175 | VLC_FOURCC('I','4','2','0') ) |
|---|
| | 176 | p_sys->b_resize_first = VLC_FALSE; |
|---|
| 180 | 177 | |
|---|
| 181 | 178 | if( p_sys->b_resize ) |
|---|
| … | … | |
| 193 | 190 | } |
|---|
| 194 | 191 | |
|---|
| | 192 | avpicture_free( &p_sys->tmp_pic ); |
|---|
| | 193 | |
|---|
| | 194 | if( p_sys->b_resize_first ) |
|---|
| | 195 | { |
|---|
| | 196 | /* Resizing then conversion */ |
|---|
| | 197 | avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma, |
|---|
| | 198 | p_filter->fmt_out.video.i_width, |
|---|
| | 199 | p_filter->fmt_out.video.i_height ); |
|---|
| | 200 | } |
|---|
| | 201 | else |
|---|
| | 202 | { |
|---|
| | 203 | /* Conversion then resizing */ |
|---|
| | 204 | avpicture_alloc( &p_sys->tmp_pic, p_sys->i_dst_ffmpeg_chroma, |
|---|
| | 205 | p_filter->fmt_in.video.i_width, |
|---|
| | 206 | p_filter->fmt_in.video.i_height ); |
|---|
| | 207 | } |
|---|
| | 208 | |
|---|
| 195 | 209 | p_sys->fmt_in = p_filter->fmt_in; |
|---|
| 196 | 210 | p_sys->fmt_out = p_filter->fmt_out; |
|---|
| … | … | |
| 209 | 223 | AVPicture *p_src, *p_dst; |
|---|
| 210 | 224 | picture_t *p_pic_dst; |
|---|
| 211 | | vlc_bool_t b_resize = p_sys->b_resize; |
|---|
| 212 | 225 | int i; |
|---|
| 213 | 226 | |
|---|
| … | … | |
| 257 | 270 | p_src = &src_pic; |
|---|
| 258 | 271 | |
|---|
| 259 | | if( b_resize && p_sys->p_rsc ) |
|---|
| | 272 | if( p_sys->b_resize && p_sys->p_rsc ) |
|---|
| 260 | 273 | { |
|---|
| 261 | 274 | p_dst = &dest_pic; |
|---|
| 262 | | if ( p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > |
|---|
| 263 | | p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height ) |
|---|
| 264 | | { |
|---|
| 265 | | if ( p_sys->b_convert ) p_dst = &p_sys->tmp_pic; |
|---|
| | 275 | if( p_sys->b_resize_first ) |
|---|
| | 276 | { |
|---|
| | 277 | if( p_sys->b_convert ) p_dst = &p_sys->tmp_pic; |
|---|
| 266 | 278 | img_resample( p_sys->p_rsc, p_dst, p_src ); |
|---|
| 267 | | b_resize = VLC_FALSE; |
|---|
| 268 | 279 | p_src = p_dst; |
|---|
| 269 | 280 | } |
|---|
| … | … | |
| 274 | 285 | video_format_t *p_fmt = &p_filter->fmt_out.video; |
|---|
| 275 | 286 | p_dst = &dest_pic; |
|---|
| 276 | | if( b_resize ) |
|---|
| | 287 | if( p_sys->b_resize && !p_sys->b_resize_first ) |
|---|
| 277 | 288 | { |
|---|
| 278 | 289 | p_dst = &p_sys->tmp_pic; |
|---|
| … | … | |
| 287 | 298 | } |
|---|
| 288 | 299 | |
|---|
| 289 | | if( b_resize && p_sys->p_rsc ) |
|---|
| | 300 | if( p_sys->b_resize && !p_sys->b_resize_first && p_sys->p_rsc ) |
|---|
| 290 | 301 | { |
|---|
| 291 | 302 | p_dst = &dest_pic; |
|---|