annotate libmpcodecs/vf_lavc.c @ 9468:356963ad4784

filter for applying 3:2 telecine to 23.976 fps progressive material. use with mencder -ofps 29.97 -fps 29.97 for proper results!
author rfelker
date Thu, 20 Feb 2003 04:57:37 +0000
parents 2670aec42989
children e39a71d9ca5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
1 #include <stdio.h>
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
2 #include <stdlib.h>
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
3 #include <string.h>
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
4 #include <inttypes.h>
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
5
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
6 #include "../config.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
7 #include "../mp_msg.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
8 #include "../help_mp.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
9
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
10 #ifdef USE_LIBAVCODEC
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
11
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
12 #include "img_format.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
13 #include "mp_image.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
14 #include "vf.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
15
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
16 //#include "../libvo/fastmemcpy.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
17
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
18 #ifdef USE_LIBAVCODEC_SO
7004
8eff71f38685 dynamic libavcodec.so support updated by
arpi
parents: 6019
diff changeset
19 #include <ffmpeg/avcodec.h>
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
20 #else
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
21 #include "libavcodec/avcodec.h"
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
22 #endif
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
23
8339
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
24 #if LIBAVCODEC_BUILD < 4641
8340
a17ce1496ca6 cleanup
michael
parents: 8339
diff changeset
25 #error we dont support libavcodec prior to build 4641, get the latest libavcodec CVS
8339
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
26 #endif
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
27
8413
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
28 #if LIBAVCODEC_BUILD < 4645
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
29 #warning your version of libavcodec is old, u might want to get a newer one
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
30 #endif
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
31
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
32 #if LIBAVCODEC_BUILD < 4645
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
33 #define AVFrame AVVideoFrame
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
34 #define coded_frame coded_picture
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
35 #endif
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
36
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
37 extern int avcodec_inited;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
38
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
39 struct vf_priv_s {
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
40 unsigned char* outbuf;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
41 int outbuf_size;
7852
e4f87bbf682c - using avcodec_alloc_context()
arpi
parents: 7368
diff changeset
42 AVCodecContext* context;
8413
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
43 AVFrame* pic;
7852
e4f87bbf682c - using avcodec_alloc_context()
arpi
parents: 7368
diff changeset
44 AVCodec* codec;
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
45 vo_mpegpes_t pes;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
46 };
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
47
7852
e4f87bbf682c - using avcodec_alloc_context()
arpi
parents: 7368
diff changeset
48 #define lavc_venc_context (*vf->priv->context)
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
49
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
50 //===========================================================================//
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
51
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
52 static int config(struct vf_instance_s* vf,
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
53 int width, int height, int d_width, int d_height,
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
54 unsigned int flags, unsigned int outfmt){
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
55 if(vf_next_query_format(vf,IMGFMT_MPEGPES)<=0) return 0;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
56
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
57 lavc_venc_context.width = width;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
58 lavc_venc_context.height = height;
6019
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
59
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
60 if(!lavc_venc_context.frame_rate){
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
61 // guess FPS:
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
62 switch(height){
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
63 case 240:
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
64 case 480:
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
65 lavc_venc_context.frame_rate=29.97*FRAME_RATE_BASE; // NTSC
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
66 break;
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
67 case 576:
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
68 case 288:
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
69 default:
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
70 lavc_venc_context.frame_rate=25*FRAME_RATE_BASE; // PAL
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
71 break;
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
72 // lavc_venc_context.frame_rate=vo_fps*FRAME_RATE_BASE; // same as src
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
73 }
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
74 }
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
75
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
76 if(vf->priv->outbuf) free(vf->priv->outbuf);
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
77
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
78 vf->priv->outbuf_size=10000+width*height; // must be enough!
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
79 vf->priv->outbuf = malloc(vf->priv->outbuf_size);
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
80
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
81 if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) {
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
82 mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
83 return 0;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
84 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
85
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
86 if (lavc_venc_context.codec->encode == NULL) {
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
87 mp_msg(MSGT_MENCODER,MSGL_ERR,"avcodec init failed (ctx->codec->encode == NULL)!\n");
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
88 return 0;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
89 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
90
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
91 return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES);
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
92 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
93
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7127
diff changeset
94 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
95 mp_image_t* dmpi;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
96 int out_size;
8413
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
97 AVFrame *pic= vf->priv->pic;
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
98
8339
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
99 pic->data[0]=mpi->planes[0];
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
100 pic->data[1]=mpi->planes[1];
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
101 pic->data[2]=mpi->planes[2];
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
102 pic->linesize[0]=mpi->stride[0];
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
103 pic->linesize[1]=mpi->stride[1];
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
104 pic->linesize[2]=mpi->stride[2];
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
105
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
106 out_size = avcodec_encode_video(&lavc_venc_context,
8339
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
107 vf->priv->outbuf, vf->priv->outbuf_size, pic);
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
108
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7127
diff changeset
109 if(out_size<=0) return 1;
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
110
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
111 dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES,
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
112 MP_IMGTYPE_EXPORT, 0,
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
113 mpi->w, mpi->h);
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
114
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
115 vf->priv->pes.data=vf->priv->outbuf;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
116 vf->priv->pes.size=out_size;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
117 vf->priv->pes.id=0x1E0;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
118 vf->priv->pes.timestamp=-1; // dunno
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
119
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 7004
diff changeset
120 dmpi->planes[0]=(unsigned char*)&vf->priv->pes;
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
121
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7127
diff changeset
122 return vf_next_put_image(vf,dmpi);
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
123 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
124
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
125 //===========================================================================//
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
126
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
127 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
128 switch(fmt){
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
129 case IMGFMT_YV12:
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
130 case IMGFMT_I420:
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
131 case IMGFMT_IYUV:
5876
arpi
parents: 5873
diff changeset
132 return (vf_next_query_format(vf,IMGFMT_MPEGPES) & (~(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE)));
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
133 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
134 return 0;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
135 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
136
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
137 static int open(vf_instance_t *vf, char* args){
6019
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
138 int p_quality=0;
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
139 float p_fps=0;
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
140
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
141 vf->config=config;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
142 vf->put_image=put_image;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
143 vf->query_format=query_format;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
144 vf->priv=malloc(sizeof(struct vf_priv_s));
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
145 memset(vf->priv,0,sizeof(struct vf_priv_s));
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
146
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
147 if (!avcodec_inited){
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
148 avcodec_init();
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
149 avcodec_register_all();
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
150 avcodec_inited=1;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
151 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
152
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
153 vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name("mpeg1video");
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
154 if (!vf->priv->codec) {
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
155 mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, "mpeg1video");
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
156 return 0;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
157 }
7852
e4f87bbf682c - using avcodec_alloc_context()
arpi
parents: 7368
diff changeset
158
e4f87bbf682c - using avcodec_alloc_context()
arpi
parents: 7368
diff changeset
159 vf->priv->context=avcodec_alloc_context();
8413
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
160 #if LIBAVCODEC_BUILD >= 4645
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
161 vf->priv->pic = avcodec_alloc_frame();
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
162 #else
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
163 vf->priv->pic = avcodec_alloc_picture();
2670aec42989 AVVideoFrame -> AVFrame
michael
parents: 8340
diff changeset
164 #endif
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
165
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
166 // TODO: parse args ->
6019
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
167 if(args) sscanf(args, "%d:%f", &p_quality, &p_fps);
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
168
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
169 if(p_quality<32){
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
170 // fixed qscale
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
171 lavc_venc_context.flags = CODEC_FLAG_QSCALE;
8339
ff0bddb59e81 support for lavc build 4641
michael
parents: 7852
diff changeset
172 vf->priv->pic->quality = (p_quality<1) ? 1 : p_quality;
6019
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
173 } else {
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
174 // fixed bitrate (in kbits)
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
175 lavc_venc_context.bit_rate = 1000*p_quality;
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
176 }
5c3b0b165f3a FPS autodetection, accept args: quality:fps
arpi
parents: 5876
diff changeset
177 lavc_venc_context.frame_rate = (p_fps<1.0) ? 0 : (p_fps * FRAME_RATE_BASE);
5873
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
178 lavc_venc_context.qmin= 1;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
179 lavc_venc_context.gop_size = 0; // I-only
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
180
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
181 return 1;
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
182 }
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
183
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
184 vf_info_t vf_info_lavc = {
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
185 "realtime mpeg1 encoding with libavcodec",
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
186 "lavc",
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
187 "A'rpi",
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
188 "",
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
189 open
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
190 };
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
191
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
192 //===========================================================================//
74cbaabeaa33 realtime yv12->mpeg1 with libavcodec qscale=1
arpi
parents:
diff changeset
193 #endif