annotate libmpcodecs/ve.c @ 33527:9f0812ccc421

Cosmetic: Adjust indent.
author ib
date Tue, 14 Jun 2011 17:53:40 +0000
parents af9ef007bec6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 27363
diff changeset
18
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
19 #include <stdio.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
20 #include <stdlib.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
21 #include <string.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
22
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15453
diff changeset
23 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15453
diff changeset
24 #include "mp_msg.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
25
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5577
diff changeset
26 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5577
diff changeset
27 #include "mp_image.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
28 #include "vf.h"
32476
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
29 #include "ve.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
30
32033
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
31 extern const vf_info_t ve_info_lavc;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
32 extern const vf_info_t ve_info_vfw;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
33 extern const vf_info_t ve_info_raw;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
34 extern const vf_info_t ve_info_libdv;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
35 extern const vf_info_t ve_info_xvid;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
36 extern const vf_info_t ve_info_qtvideo;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
37 extern const vf_info_t ve_info_nuv;
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30633
diff changeset
38 extern const vf_info_t ve_info_x264;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
39
25876
edfe8baed49f copy note on new demuxers and codecs to the top of the array as well to be
ivo
parents: 25872
diff changeset
40 /* Please do not add any new encoders here. If you want to implement a new
25880
4df11ac927fc clarify comments/docs about lav* being the preferred place to implement new
ivo
parents: 25876
diff changeset
41 * encoder, add it to libavcodec, except for wrappers around external
4df11ac927fc clarify comments/docs about lav* being the preferred place to implement new
ivo
parents: 25876
diff changeset
42 * libraries and encoders requiring binary support. */
25876
edfe8baed49f copy note on new demuxers and codecs to the top of the array as well to be
ivo
parents: 25872
diff changeset
43
32035
bc01ea7a6322 Mark encoder_list declaration as const pointers to const data, fixes:
diego
parents: 32033
diff changeset
44 static const vf_info_t * const encoder_list[] = {
32142
4614728cab25 build system: Merge all FFmpeg library checks into a single FFmpeg check.
diego
parents: 32035
diff changeset
45 #ifdef CONFIG_FFMPEG
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
46 &ve_info_lavc,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
47 #endif
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26513
diff changeset
48 #ifdef CONFIG_WIN32DLL
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
49 &ve_info_vfw,
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26513
diff changeset
50 #ifdef CONFIG_QTX_CODECS_WIN32
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents: 7456
diff changeset
51 &ve_info_qtvideo,
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
52 #endif
15453
d7a2ffc6e694 compilation/link fix with --disable-qtx --disable-dshow
diego
parents: 13166
diff changeset
53 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
54 #ifdef CONFIG_LIBDV095
5577
80eedd3ef6d3 RGB24/YUY2 -> DV encoding, using libdv
arpi
parents: 5550
diff changeset
55 &ve_info_libdv,
80eedd3ef6d3 RGB24/YUY2 -> DV encoding, using libdv
arpi
parents: 5550
diff changeset
56 #endif
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents: 11581
diff changeset
57 &ve_info_raw,
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
58 #ifdef CONFIG_XVID4
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents: 5607
diff changeset
59 &ve_info_xvid,
dacc262f41ba Support for XviD encoding
kmkaplan
parents: 5607
diff changeset
60 #endif
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26513
diff changeset
61 #ifdef CONFIG_LIBLZO
9520
2860f7c9d9ca A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents: 8471
diff changeset
62 &ve_info_nuv,
22244
675574bebb04 Make liblzo conditional to the appropriate #defines.
diego
parents: 20984
diff changeset
63 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
64 #ifdef CONFIG_X264
13166
d198f255bee9 x264 encoder support. Original patch send by Bernhard Rosenkraenzer <bero at arklinux dot org>, modifications by Loren Merritt <lorenm at u.washington dot edu>, Jeff Clagg <snacky at ikaruga.co dot uk> and me
iive
parents: 11966
diff changeset
65 &ve_info_x264,
d198f255bee9 x264 encoder support. Original patch send by Bernhard Rosenkraenzer <bero at arklinux dot org>, modifications by Loren Merritt <lorenm at u.washington dot edu>, Jeff Clagg <snacky at ikaruga.co dot uk> and me
iive
parents: 11966
diff changeset
66 #endif
25872
3eeaf9d4c65a note on new demuxers and codecs, add them to lav* instead of libmp*
ivo
parents: 22244
diff changeset
67 /* Please do not add any new encoders here. If you want to implement a new
25880
4df11ac927fc clarify comments/docs about lav* being the preferred place to implement new
ivo
parents: 25876
diff changeset
68 * encoder, add it to libavcodec, except for wrappers around external
4df11ac927fc clarify comments/docs about lav* being the preferred place to implement new
ivo
parents: 25876
diff changeset
69 * libraries and encoders requiring binary support. */
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
70 NULL
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
71 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
72
18980
ed69754aa58d Marks several string parameters as const when they are not modified in the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 17012
diff changeset
73 vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args){
9595
6bf482d797b1 1000L i forgot mencoder
albeu
parents: 9520
diff changeset
74 char* vf_args[] = { "_oldargs_", args, NULL };
6bf482d797b1 1000L i forgot mencoder
albeu
parents: 9520
diff changeset
75 return vf_open_plugin(encoder_list,next,name,vf_args);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
76 }
32476
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
77
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
78 static double *forced_key_frames_ts;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
79 static int forced_key_frames_number;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
80 static int forced_key_frames_idx;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
81
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
82 int parse_forced_key_frames(const m_option_t *opt, const char *arg)
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
83 {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
84 double ts;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
85 const char *p;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
86 int nts = 1, idx = 0, len;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
87
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
88 for (p = arg; *p; p++)
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
89 nts += *p == ',';
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
90 free(forced_key_frames_ts);
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
91 forced_key_frames_ts = calloc(sizeof(*forced_key_frames_ts), nts);
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
92 p = arg;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
93 while (1) {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
94 len = parse_timestring(p, &ts, ',');
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
95 if (!len) {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
96 mp_msg(MSGT_CFGPARSER, MSGL_ERR,
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
97 "Option force-key-frames: invalid time: '%s'\n", p);
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
98 return M_OPT_INVALID;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
99 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
100 forced_key_frames_ts[idx++] = ts;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
101 if (!p[len])
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
102 break;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
103 p += len + 1;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
104 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
105 forced_key_frames_number = idx;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
106 forced_key_frames_idx = 0;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
107 for (idx = 1; idx < forced_key_frames_number; idx++) {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
108 if (forced_key_frames_ts[idx - 1] >= forced_key_frames_ts[idx]) {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
109 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option force-key-frames: "
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
110 "timestamps are not in ascending order\n");
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
111 return M_OPT_INVALID;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
112 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
113 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
114 return 0;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
115 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
116
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
117 int is_forced_key_frame(double pts)
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
118 {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
119 if (forced_key_frames_idx < forced_key_frames_number &&
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
120 pts >= forced_key_frames_ts[forced_key_frames_idx]) {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
121 forced_key_frames_idx++;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
122 if (forced_key_frames_idx >= forced_key_frames_number) {
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
123 free(forced_key_frames_ts);
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
124 forced_key_frames_number = 0;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
125 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
126 return 1;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
127 }
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
128 return 0;
af9ef007bec6 Add the -force-key-frames option.
cigaes
parents: 32142
diff changeset
129 }