Mercurial > mplayer.hg
annotate libmpcodecs/vd_ffmpeg.c @ 7127:1e47c2e7aa8e
mostly compiler warning fixes, some small bugfix
patch by Dominik Mierzejewski <dominik@rangers.eu.org>
author | arpi |
---|---|
date | Wed, 28 Aug 2002 22:45:48 +0000 |
parents | d3fd5d568594 |
children | 28677d779205 |
rev | line source |
---|---|
4952 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <assert.h> | |
6828
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
4 #include <time.h> |
4952 | 5 |
6 #include "config.h" | |
7 #include "mp_msg.h" | |
8 #include "help_mp.h" | |
9 | |
10 #ifdef USE_LIBAVCODEC | |
11 | |
12 #include "bswap.h" | |
13 | |
14 #include "vd_internal.h" | |
15 | |
16 static vd_info_t info = { | |
17 "FFmpeg's libavcodec codec family", | |
18 "ffmpeg", | |
19 VFM_FFMPEG, | |
20 "A'rpi", | |
21 "http://ffmpeg.sf.net", | |
22 "native codecs" | |
23 }; | |
24 | |
25 LIBVD_EXTERN(ffmpeg) | |
26 | |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
27 #include "../postproc/rgb2rgb.h" |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
28 |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
29 |
4952 | 30 #ifdef USE_LIBAVCODEC_SO |
7004 | 31 #include <ffmpeg/avcodec.h> |
4952 | 32 #else |
33 #include "libavcodec/avcodec.h" | |
34 #endif | |
35 | |
36 int avcodec_inited=0; | |
37 | |
5517 | 38 #ifdef FF_POSTPROCESS |
39 int quant_store[MBR+1][MBC+1]; | |
40 #endif | |
41 | |
5280 | 42 typedef struct { |
43 AVCodecContext *avctx; | |
5482 | 44 int last_aspect; |
45 int do_slices; | |
6734 | 46 int do_dr1; |
5482 | 47 int vo_inited; |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
48 int convert; |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
49 int best_csp; |
5280 | 50 } vd_ffmpeg_ctx; |
51 | |
4952 | 52 //#ifdef FF_POSTPROCESS |
53 //unsigned int lavc_pp=0; | |
54 //#endif | |
55 | |
6265
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
56 #include "cfgparser.h" |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
57 |
6739 | 58 static void get_buffer(struct AVCodecContext *avctx, int width, int height, int pict_type); |
59 | |
6265
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
60 static int lavc_param_workaround_bugs=0; |
6897 | 61 static int lavc_param_error_resilience=-1; |
6355 | 62 static int lavc_param_gray=0; |
6828
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
63 static int lavc_param_vstats=0; |
6265
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
64 |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
65 struct config lavc_decode_opts_conf[]={ |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
66 #if LIBAVCODEC_BUILD >= 4611 |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
67 {"bug", &lavc_param_workaround_bugs, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL}, |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
68 {"ver", &lavc_param_error_resilience, CONF_TYPE_INT, CONF_RANGE, -1, 99, NULL}, |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
69 #endif |
6355 | 70 #if LIBAVCODEC_BUILD >= 4614 |
71 {"gray", &lavc_param_gray, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL}, | |
72 #endif | |
6869 | 73 {"vstats", &lavc_param_vstats, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
6265
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
74 {NULL, NULL, 0, 0, 0, 0, NULL} |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
75 }; |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
76 |
4952 | 77 // to set/get/query special features/parameters |
78 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
79 vd_ffmpeg_ctx *ctx = sh->context; |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
80 AVCodecContext *avctx = ctx->avctx; |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
81 switch(cmd){ |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
82 case VDCTRL_QUERY_FORMAT: |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
83 if( (*((int*)arg)) == ctx->best_csp ) return CONTROL_TRUE;//supported |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
84 // possible conversions: |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
85 switch( (*((int*)arg)) ){ |
6739 | 86 case IMGFMT_YV12: |
87 case IMGFMT_IYUV: | |
88 case IMGFMT_I420: | |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
89 // "converted" using pointer/stride modification |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
90 if(avctx->pix_fmt==PIX_FMT_YUV420P) return CONTROL_TRUE;// u/v swap |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
91 if(avctx->pix_fmt==PIX_FMT_YUV422P) return CONTROL_TRUE;// half stride |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
92 break; |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
93 #if 1 |
6739 | 94 case IMGFMT_YUY2: |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
95 // converted using yuv422ptoyuy2() |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
96 if(avctx->pix_fmt==PIX_FMT_YUV422P) return CONTROL_TRUE; |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
97 break; |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
98 } |
6681 | 99 #endif |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
100 return CONTROL_FALSE; |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
101 } |
4952 | 102 return CONTROL_UNKNOWN; |
103 } | |
104 | |
105 // init driver | |
106 static int init(sh_video_t *sh){ | |
5280 | 107 AVCodecContext *avctx; |
108 vd_ffmpeg_ctx *ctx; | |
5457
f248c9e86423
config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents:
5331
diff
changeset
|
109 AVCodec *lavc_codec; |
4952 | 110 |
111 if(!avcodec_inited){ | |
112 avcodec_init(); | |
113 avcodec_register_all(); | |
114 avcodec_inited=1; | |
115 } | |
5280 | 116 |
117 ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx)); | |
118 if (!ctx) | |
119 return(0); | |
120 memset(ctx, 0, sizeof(vd_ffmpeg_ctx)); | |
4952 | 121 |
5457
f248c9e86423
config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents:
5331
diff
changeset
|
122 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll); |
f248c9e86423
config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents:
5331
diff
changeset
|
123 if(!lavc_codec){ |
4952 | 124 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh->codec->dll); |
125 return 0; | |
126 } | |
5482 | 127 |
5494
1c45b1484ffb
i just fixed b-frames & slices in libavcodec :) ... iam too tired for benchmarks now ...
michael
parents:
5482
diff
changeset
|
128 if(vd_use_slices && lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) |
1c45b1484ffb
i just fixed b-frames & slices in libavcodec :) ... iam too tired for benchmarks now ...
michael
parents:
5482
diff
changeset
|
129 ctx->do_slices=1; |
6734 | 130 |
6736 | 131 #if LIBAVCODEC_BUILD > 4615 |
6735 | 132 if(lavc_codec->capabilities&CODEC_CAP_DR1) |
6734 | 133 ctx->do_dr1=1; |
6736 | 134 #endif |
135 | |
5280 | 136 ctx->avctx = malloc(sizeof(AVCodecContext)); |
137 memset(ctx->avctx, 0, sizeof(AVCodecContext)); | |
138 avctx = ctx->avctx; | |
6739 | 139 |
140 #if LIBAVCODEC_BUILD > 4615 | |
141 if(ctx->do_dr1){ | |
142 avctx->flags|= CODEC_FLAG_EMU_EDGE | CODEC_FLAG_DR1; | |
143 avctx->get_buffer_callback= get_buffer; | |
144 } | |
145 #endif | |
4952 | 146 |
5280 | 147 avctx->width = sh->disp_w; |
148 avctx->height= sh->disp_h; | |
6265
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
149 #if LIBAVCODEC_BUILD >= 4611 |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
150 avctx->workaround_bugs= lavc_param_workaround_bugs; |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
151 avctx->error_resilience= lavc_param_error_resilience; |
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
152 #endif |
6355 | 153 #if LIBAVCODEC_BUILD >= 4614 |
154 if(lavc_param_gray) avctx->flags|= CODEC_FLAG_GRAY; | |
155 #endif | |
6265
f49ec39ab0c6
workaround bugs & error resilience ffmpeg decoder options
michael
parents:
5940
diff
changeset
|
156 |
5280 | 157 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",avctx->width,avctx->height); |
4952 | 158 if (sh->format == mmioFOURCC('R', 'V', '1', '3')) |
5280 | 159 avctx->sub_id = 3; |
5939 | 160 #if LIBAVCODEC_BUILD >= 4605 |
161 /* AVRn stores huffman table in AVI header */ | |
162 /* Pegasus MJPEG stores it also in AVI header, but it uses the common | |
163 MJPG fourcc :( */ | |
5940 | 164 if (sh->bih && (sh->bih->biSize != sizeof(BITMAPINFOHEADER)) && |
5939 | 165 (sh->format == mmioFOURCC('A','V','R','n') || |
166 sh->format == mmioFOURCC('M','J','P','G'))) | |
167 { | |
168 avctx->flags |= CODEC_FLAG_EXTERN_HUFF; | |
169 avctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER); | |
170 avctx->extradata = malloc(avctx->extradata_size); | |
171 memcpy(avctx->extradata, sh->bih+sizeof(BITMAPINFOHEADER), | |
172 avctx->extradata_size); | |
173 | |
174 #if 0 | |
175 { | |
176 int x; | |
177 uint8_t *p = avctx->extradata; | |
178 | |
179 for (x=0; x<avctx->extradata_size; x++) | |
180 printf("[%x] ", p[x]); | |
181 printf("\n"); | |
182 } | |
183 #endif | |
184 } | |
185 #endif | |
7126 | 186 if( sh->format == mmioFOURCC('R', 'V', '1', '0') |
187 || sh->format == mmioFOURCC('R', 'V', '1', '3')){ | |
188 unsigned int* extrahdr=(unsigned int*)(sh->bih+1); | |
189 avctx->extradata_size= 8; | |
190 avctx->extradata = malloc(avctx->extradata_size); | |
191 ((uint32_t*)avctx->extradata)[0] = extrahdr[0]; | |
192 ((uint32_t*)avctx->extradata)[1] = extrahdr[1]; | |
193 // printf("%X %X %d %d\n", extrahdr[0], extrahdr[1]); | |
194 } | |
195 | |
4952 | 196 /* open it */ |
5457
f248c9e86423
config vo only if aspect really changed and width&&height isn't changed (if w||h changes, we set it later)
alex
parents:
5331
diff
changeset
|
197 if (avcodec_open(avctx, lavc_codec) < 0) { |
4952 | 198 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec); |
199 return 0; | |
200 } | |
201 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); | |
5482 | 202 ctx->last_aspect=-3; |
5510 | 203 return 1; //mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); |
4952 | 204 } |
205 | |
206 // uninit driver | |
207 static void uninit(sh_video_t *sh){ | |
5280 | 208 vd_ffmpeg_ctx *ctx = sh->context; |
209 AVCodecContext *avctx = ctx->avctx; | |
210 | |
211 if (avcodec_close(avctx) < 0) | |
4952 | 212 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); |
5939 | 213 |
214 #if LIBAVCODEC_BUILD >= 4605 | |
215 if (avctx->extradata_size) | |
216 free(avctx->extradata); | |
217 #endif | |
218 | |
5280 | 219 if (avctx) |
220 free(avctx); | |
221 if (ctx) | |
222 free(ctx); | |
4952 | 223 } |
224 | |
5482 | 225 static void draw_slice(struct AVCodecContext *s, |
226 UINT8 **src, int linesize, | |
227 int y, int width, int height){ | |
6710 | 228 sh_video_t * sh = s->opaque; |
5482 | 229 int stride[3]; |
6740 | 230 int start=0, i; |
231 int skip_stride= (s->width+15)>>4; | |
6869 | 232 #if LIBAVCODEC_BUILD > 4615 |
6740 | 233 UINT8 *skip= &s->mbskip_table[(y>>4)*skip_stride]; |
234 int threshold= s->pict_type==B_TYPE ? -99 : s->dr_ip_buffer_count; | |
235 #endif | |
5482 | 236 |
237 stride[0]=linesize; | |
6740 | 238 #if LIBAVCODEC_BUILD > 4615 |
239 if(s->dr_uvstride) | |
240 stride[1]=stride[2]= s->dr_uvstride; | |
241 else | |
242 #endif | |
243 stride[1]=stride[2]=stride[0]/2; | |
244 #if 0 | |
245 if(s->pict_type!=B_TYPE){ | |
246 for(i=0; i*16<width+16; i++){ | |
247 if(i*16>=width || skip[i]>=threshold){ | |
248 if(start==i) start++; | |
249 else{ | |
250 UINT8 *src2[3]= {src[0] + start*16, | |
251 src[1] + start*8, | |
252 src[2] + start*8}; | |
253 //printf("%2d-%2d x %d\n", start, i, y); | |
254 mpcodecs_draw_slice (sh,src2, stride, (i-start)*16, height, start*16, y); | |
255 start= i+1; | |
256 } | |
257 } | |
258 } | |
259 }else | |
260 #endif | |
7127 | 261 mpcodecs_draw_slice (sh,(unsigned char*)src, stride, width, height, 0, y); |
5482 | 262 } |
4952 | 263 |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
264 static int init_vo(sh_video_t *sh){ |
5280 | 265 vd_ffmpeg_ctx *ctx = sh->context; |
266 AVCodecContext *avctx = ctx->avctx; | |
4952 | 267 |
5482 | 268 if (avctx->aspect_ratio_info != ctx->last_aspect || |
269 avctx->width != sh->disp_w || | |
270 avctx->height != sh->disp_h || | |
271 !ctx->vo_inited) | |
5280 | 272 { |
273 ctx->last_aspect = avctx->aspect_ratio_info; | |
274 switch(avctx->aspect_ratio_info) | |
275 { | |
276 case FF_ASPECT_4_3_625: | |
277 case FF_ASPECT_4_3_525: | |
278 sh->aspect = 4.0/3.0; | |
279 break; | |
280 case FF_ASPECT_16_9_625: | |
281 case FF_ASPECT_16_9_525: | |
282 sh->aspect = 16.0/9.0; | |
283 break; | |
284 case FF_ASPECT_SQUARE: | |
285 sh->aspect = 0.0; | |
286 break; | |
287 } | |
5482 | 288 sh->disp_w = avctx->width; |
289 sh->disp_h = avctx->height; | |
290 ctx->vo_inited=1; | |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
291 switch(avctx->pix_fmt){ |
6681 | 292 #if LIBAVCODEC_BUILD >= 4615 |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
293 case PIX_FMT_YUV410P: ctx->best_csp=IMGFMT_YVU9;break; //svq1 |
6681 | 294 #endif |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
295 case PIX_FMT_YUV420P: ctx->best_csp=IMGFMT_YV12;break; //mpegs |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
296 case PIX_FMT_YUV422P: ctx->best_csp=IMGFMT_422P;break; //mjpeg |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
297 case PIX_FMT_YUV444P: ctx->best_csp=IMGFMT_444P;break; //??? |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
298 case PIX_FMT_YUV422: ctx->best_csp=IMGFMT_YUY2;break; //??? |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
299 default: |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
300 ctx->best_csp=0; |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
301 } |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
302 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h, ctx->best_csp)) |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
303 return -1; |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
304 ctx->convert=(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_YUY2 |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
305 && ctx->best_csp!=IMGFMT_YUY2); // yuv422p->yuy2 conversion |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
306 } |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
307 return 0; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
308 } |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
309 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
310 #if LIBAVCODEC_BUILD > 4615 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
311 static void get_buffer(struct AVCodecContext *avctx, int width, int height, int pict_type){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
312 sh_video_t * sh = avctx->opaque; |
6734 | 313 vd_ffmpeg_ctx *ctx = sh->context; |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
314 mp_image_t* mpi=NULL; |
6875 | 315 int flags= MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE; |
6737 | 316 int type= MP_IMGTYPE_IPB; |
6738 | 317 int align=15; |
318 | |
319 if(avctx->pix_fmt == PIX_FMT_YUV410P) | |
320 align=63; //yes seriously, its really needed (16x16 chroma blocks in SVQ1 -> 64x64) | |
321 | |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
322 if(init_vo(sh)<0){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
323 printf("init_vo failed\n"); |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
324 return; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
325 } |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
326 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
327 if(pict_type==B_TYPE) |
6734 | 328 flags|=(!avctx->hurry_up && ctx->do_slices) ? |
329 MP_IMGFLAG_DRAW_CALLBACK:0; | |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
330 else |
6742
93bce3460e2a
fallback to slices, if dr1 fails (bug found by kabi)
michael
parents:
6740
diff
changeset
|
331 flags|= MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE |
93bce3460e2a
fallback to slices, if dr1 fails (bug found by kabi)
michael
parents:
6740
diff
changeset
|
332 | (ctx->do_slices ? MP_IMGFLAG_DRAW_CALLBACK : 0); |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
333 |
6737 | 334 #if LIBAVCODEC_BUILD > 4616 |
335 if(avctx->has_b_frames){ | |
336 type= MP_IMGTYPE_IPB; | |
337 }else{ | |
338 type= MP_IMGTYPE_IP; | |
339 } | |
340 #endif | |
341 mp_msg(MSGT_DECVIDEO,MSGL_DBG2, type== MP_IMGTYPE_IPB ? "using IPB\n" : "using IP\n"); | |
342 | |
343 mpi= mpcodecs_get_image(sh,type, flags, | |
6738 | 344 (width+align)&(~align), (height+align)&(~align)); |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
345 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
346 // ok, lets see what did we get: |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
347 if( mpi->flags&MP_IMGFLAG_DRAW_CALLBACK && |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
348 !(mpi->flags&MP_IMGFLAG_DIRECT)){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
349 // nice, filter/vo likes draw_callback :) |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
350 avctx->draw_horiz_band= draw_slice; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
351 } else |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
352 avctx->draw_horiz_band= NULL; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
353 avctx->dr_buffer[0]= mpi->planes[0]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
354 avctx->dr_buffer[1]= mpi->planes[1]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
355 avctx->dr_buffer[2]= mpi->planes[2]; |
6734 | 356 |
357 if(avctx->dr_stride && avctx->dr_stride !=mpi->stride[0]){ | |
358 mp_msg(MSGT_DECVIDEO,MSGL_ERR, "Error: stride changed\n"); | |
359 } | |
6869 | 360 |
361 if(avctx->dr_uvstride && avctx->dr_uvstride !=mpi->stride[1]){ | |
362 mp_msg(MSGT_DECVIDEO,MSGL_ERR, "Error: uvstride changed\n"); | |
363 } | |
7051
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
364 |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
365 assert(mpi->width >= ((width +align)&(~align))); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
366 assert(mpi->height >= ((height+align)&(~align))); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
367 assert(mpi->stride[0] >= mpi->width); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
368 if(mpi->imgfmt==IMGFMT_I420 || mpi->imgfmt==IMGFMT_YV12 || mpi->imgfmt==IMGFMT_IYUV){ |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
369 const int y_size= mpi->stride[0] * mpi->height; |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
370 const int c_size= mpi->stride[1] * mpi->chroma_height; |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
371 |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
372 assert(mpi->planes[0] > mpi->planes[1] || mpi->planes[0] + y_size <= mpi->planes[1]); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
373 assert(mpi->planes[0] > mpi->planes[2] || mpi->planes[0] + y_size <= mpi->planes[2]); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
374 assert(mpi->planes[1] > mpi->planes[0] || mpi->planes[1] + c_size <= mpi->planes[0]); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
375 assert(mpi->planes[1] > mpi->planes[2] || mpi->planes[1] + c_size <= mpi->planes[2]); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
376 assert(mpi->planes[2] > mpi->planes[0] || mpi->planes[2] + c_size <= mpi->planes[0]); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
377 assert(mpi->planes[2] > mpi->planes[1] || mpi->planes[2] + c_size <= mpi->planes[1]); |
d03fad6123a3
asserts to check buffer size and non overlapingness
michael
parents:
7004
diff
changeset
|
378 } |
6734 | 379 |
380 avctx->dr_stride = mpi->stride[0]; | |
6737 | 381 avctx->dr_uvstride = mpi->stride[1]; |
6734 | 382 |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
383 avctx->dr_opaque_frame = mpi; |
6737 | 384 avctx->dr_ip_buffer_count=2; //FIXME |
6742
93bce3460e2a
fallback to slices, if dr1 fails (bug found by kabi)
michael
parents:
6740
diff
changeset
|
385 //printf("%X\n", (int)mpi->planes[0]); |
6869 | 386 #if 0 |
387 if(mpi->flags&MP_IMGFLAG_DIRECT) | |
388 printf("D"); | |
389 else if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) | |
390 printf("S"); | |
391 else | |
392 printf("."); | |
393 #endif | |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
394 } |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
395 #endif |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
396 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
397 // decode a frame |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
398 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
399 int got_picture=0; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
400 int ret; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
401 AVPicture lavc_picture; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
402 vd_ffmpeg_ctx *ctx = sh->context; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
403 AVCodecContext *avctx = ctx->avctx; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
404 mp_image_t* mpi=NULL; |
6737 | 405 int dr1= ctx->do_dr1; |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
406 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
407 if(len<=0) return NULL; // skipped frame |
6734 | 408 |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
409 avctx->draw_horiz_band=NULL; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
410 avctx->opaque=sh; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
411 if(ctx->vo_inited && !ctx->convert && !(flags&3) && !dr1){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
412 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE | |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
413 (ctx->do_slices?MP_IMGFLAG_DRAW_CALLBACK:0), |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
414 sh->disp_w, sh->disp_h); |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
415 if(mpi && mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
416 // vd core likes slices! |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
417 avctx->draw_horiz_band=draw_slice; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
418 } |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
419 } |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
420 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
421 #if LIBAVCODEC_BUILD > 4603 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
422 avctx->hurry_up=(flags&3)?((flags&2)?2:1):0; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
423 #endif |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
424 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
425 ret = avcodec_decode_video(avctx, &lavc_picture, |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
426 &got_picture, data, len); |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
427 if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n"); |
6828
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
428 |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
429 //-- vstats generation |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
430 while(lavc_param_vstats){ // always one time loop |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
431 static FILE *fvstats=NULL; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
432 char filename[20]; |
6834
2d7dfcc79651
Fix overall frametime overflow, hopefully long long int is portable. (untested, will test tomorrow)
atmos4
parents:
6833
diff
changeset
|
433 static long long int all_len=0; |
6828
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
434 static int frame_number=0; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
435 static double all_frametime=0.0; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
436 |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
437 if(!fvstats) { |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
438 time_t today2; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
439 struct tm *today; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
440 today2 = time(NULL); |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
441 today = localtime(&today2); |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
442 sprintf(filename, "vstats_%02d%02d%02d.log", today->tm_hour, |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
443 today->tm_min, today->tm_sec); |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
444 fvstats = fopen(filename,"w"); |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
445 if(!fvstats) { |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
446 perror("fopen"); |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
447 lavc_param_vstats=0; // disable block |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
448 break; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
449 /*exit(1);*/ |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
450 } |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
451 } |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
452 |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
453 all_len+=len; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
454 all_frametime+=sh->frametime; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
455 fprintf(fvstats, "frame= %5d q= %2d f_size= %6d s_size= %8.0fkB ", |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
456 ++frame_number, avctx->quality, len, (double)all_len/1024); |
6833
a709a7662cd1
Add type= and fix a minor typing difference from ffmpeg
atmos4
parents:
6828
diff
changeset
|
457 fprintf(fvstats, "time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", |
6828
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
458 all_frametime, (double)(len*8)/sh->frametime/1000.0, |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
459 (double)(all_len*8)/all_frametime/1000.0); |
6833
a709a7662cd1
Add type= and fix a minor typing difference from ffmpeg
atmos4
parents:
6828
diff
changeset
|
460 fprintf(fvstats, "type= %c\n", sh->ds->flags&1 ? 'I' : 'P'); |
6828
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
461 break; |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
462 } |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
463 //-- |
010be15e48ad
Generate ffmpeg compatible vstats_<time>.log, when -lavdopts vstats is specified.
atmos4
parents:
6771
diff
changeset
|
464 |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
465 if(!got_picture) return NULL; // skipped image |
6738 | 466 |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
467 if(init_vo(sh)<0) return NULL; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
468 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
469 #if LIBAVCODEC_BUILD > 4615 |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
470 if(dr1 && avctx->dr_opaque_frame){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
471 mpi= (mp_image_t*)avctx->dr_opaque_frame; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
472 } |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
473 #endif |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
474 |
5592
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
475 if(!mpi && ctx->convert){ |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
476 // do yuv422p -> yuy2 conversion: |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
477 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
478 avctx->width, avctx->height); |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
479 if(!mpi) return NULL; |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
480 yuv422ptoyuy2(lavc_picture.data[0],lavc_picture.data[1],lavc_picture.data[2], |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
481 mpi->planes[0],avctx->width,avctx->height, |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
482 lavc_picture.linesize[0],lavc_picture.linesize[1],mpi->stride[0]); |
b545d56314d2
yuy2 support, fixed bug of dropping frame after config_vo calls
arpi
parents:
5517
diff
changeset
|
483 return mpi; |
5280 | 484 } |
4952 | 485 |
5482 | 486 if(!mpi) |
4952 | 487 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, |
5280 | 488 avctx->width, avctx->height); |
4952 | 489 if(!mpi){ // temporary! |
5207
d337cc4ab0ee
config vo if resolution changed (after decoded image read the dimensions out of lavc context)
alex
parents:
5124
diff
changeset
|
490 printf("couldn't allocate image for codec\n"); |
4952 | 491 return NULL; |
492 } | |
493 | |
6733
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
494 if(!dr1){ |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
495 mpi->planes[0]=lavc_picture.data[0]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
496 mpi->planes[1]=lavc_picture.data[1]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
497 mpi->planes[2]=lavc_picture.data[2]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
498 mpi->stride[0]=lavc_picture.linesize[0]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
499 mpi->stride[1]=lavc_picture.linesize[1]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
500 mpi->stride[2]=lavc_picture.linesize[2]; |
3b1f37fc0693
direct rendering method 1 (disabled currently as its not bugfree / finished yet, just set dr1=1 if u want to try it)
michael
parents:
6710
diff
changeset
|
501 } |
4952 | 502 |
6873
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
503 if(avctx->pix_fmt==PIX_FMT_YUV422P && mpi->chroma_y_shift==1){ |
1206fa765697
colorspace part cleanup and support for IMGFMT_422P, _444P
arpi
parents:
6869
diff
changeset
|
504 // we have 422p but user wants 420p |
4952 | 505 mpi->stride[1]*=2; |
506 mpi->stride[2]*=2; | |
507 } | |
508 | |
6665 | 509 /* to comfirm with newer lavc style */ |
510 #if !defined(FF_POSTPROCESS) && (LIBAVCODEC_BUILD > 4612) | |
511 mpi->qscale=avctx->quant_store; | |
512 #if LIBAVCODEC_BUILD > 4613 | |
513 mpi->qstride=avctx->qstride; | |
514 #else | |
515 mpi->qstride=MBC+1; | |
516 #endif | |
6771 | 517 #elif defined(FF_POSTPROCESS) |
5517 | 518 mpi->qscale=&quant_store[0][0]; |
519 mpi->qstride=MBC+1; | |
520 #endif | |
521 | |
4952 | 522 return mpi; |
523 } | |
524 | |
525 #endif | |
526 |