annotate libmpcodecs/ve_x264.c @ 35999:135a2c940db8

Remove HideSkinBrowser(). Simply destroy the window. (It's pointless to check whether the window is existing, because it cannot be called without an existing window.)
author ib
date Fri, 29 Mar 2013 17:15:19 +0000
parents 9b4ba0fb999b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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:
diff changeset
1 /*****************************************************************************
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:
diff changeset
2 *
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:
diff changeset
3 * - H.264 encoder for mencoder using 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:
diff changeset
4 *
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:
diff changeset
5 * Copyright (C) 2004 LINUX4MEDIA GmbH
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:
diff changeset
6 * Copyright (C) 2004 Ark Linux
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:
diff changeset
7 *
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:
diff changeset
8 * Written by Bernhard Rosenkraenzer <bero@arklinux.org>
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:
diff changeset
9 *
26647
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
10 * This file is part of MPlayer.
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:
diff changeset
11 *
26647
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
12 * MPlayer is free software; you can redistribute it and/or modify
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
13 * it under the terms of the GNU General Public License as published by
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
15 * (at your option) any later version.
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
16 *
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
17 * MPlayer is distributed in the hope that it will be useful,
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:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26647
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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:
diff changeset
20 * GNU General Public License for more details.
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:
diff changeset
21 *
26647
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
22 * You should have received a copy of the GNU General Public License along
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
23 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bd0554dbc8e5 Relicense file as GPL v2+; bero granted permission on IRC.
diego
parents: 25607
diff changeset
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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:
diff changeset
25 *
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:
diff changeset
26 *****************************************************************************/
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:
diff changeset
27
35951
9b4ba0fb999b build: Add _BSD_SOURCE definition for strsep().
diego
parents: 35903
diff changeset
28 #define _BSD_SOURCE
9b4ba0fb999b build: Add _BSD_SOURCE definition for strsep().
diego
parents: 35903
diff changeset
29
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:
diff changeset
30 #include <stdio.h>
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:
diff changeset
31 #include <stdlib.h>
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:
diff changeset
32 #include <string.h>
35903
389d43c448b3 Add missing strings.h #includes for strcasecmp().
diego
parents: 33251
diff changeset
33 #include <strings.h>
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:
diff changeset
34 #include <errno.h>
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:
diff changeset
35
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16898
diff changeset
36 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16898
diff changeset
37 #include "mp_msg.h"
32064
a735105a66b6 Move all MEncoder-related extern variable declarations to mencoder.h.
diego
parents: 32033
diff changeset
38 #include "mencoder.h"
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:
diff changeset
39 #include "m_option.h"
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:
diff changeset
40 #include "codec-cfg.h"
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 22158
diff changeset
41 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
42 #include "libmpdemux/demuxer.h"
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
43 #include "libmpdemux/stheader.h"
33251
7d13ed4e80f2 Add missing osdep/strsep.h #include where strsep() is used.
diego
parents: 32527
diff changeset
44 #include "osdep/strsep.h"
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 22158
diff changeset
45 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
46 #include "libmpdemux/muxer.h"
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:
diff changeset
47
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:
diff changeset
48 #include "img_format.h"
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:
diff changeset
49 #include "mp_image.h"
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:
diff changeset
50 #include "vf.h"
32478
87870a8a114a Support for -force-key-frames for ve_x264.
cigaes
parents: 32123
diff changeset
51 #include "ve.h"
30949
e4c7703dd901 Add a header for x264enc_set_param() instead of forward declaring it.
diego
parents: 30748
diff changeset
52 #include "ve_x264.h"
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:
diff changeset
53
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:
diff changeset
54 #include <x264.h>
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:
diff changeset
55
25607
9d0b189ce1b2 Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents: 25570
diff changeset
56 typedef struct h264_module_t {
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:
diff changeset
57 muxer_stream_t *mux;
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:
diff changeset
58 x264_t * 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:
diff changeset
59 x264_picture_t pic;
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:
diff changeset
60 } h264_module_t;
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:
diff changeset
61
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
62 static x264_param_t param;
20317
50584bb892c0 make any parse error in -x264encopts fatal
lorenm
parents: 20297
diff changeset
63 static int parse_error = 0;
16366
e054a3c93a26 custom quantization matrix for x264, original patch by Robert Swain < robert POUM swain AH gmail POUM com>
gpoirier
parents: 16016
diff changeset
64
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
65 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts);
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
66 static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in);
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:
diff changeset
67
25232
893db6cc97b2 Add appropriate const specifiers to some custom parse functions.
reimar
parents: 22601
diff changeset
68 void x264enc_set_param(const m_option_t* opt, char* arg)
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
69 {
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
70 static int initialized = 0;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
71 int slow_firstpass = 0;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
72 char *preset = NULL, *tune = NULL, *profile = NULL;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
73 char *p, *copy, *name;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
74
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
75 if (!initialized) {
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
76 x264_param_default(&param);
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
77 initialized = 1;
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
78 }
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
79 if (!arg) {
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
80 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option x264encopts: no options provided\n");
22032
62d7b935df2e fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents: 21660
diff changeset
81 parse_error = 1;
62d7b935df2e fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents: 21660
diff changeset
82 return;
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
83 } else if (!*arg)
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
84 /* Empty arguments, just doing initialization of default parameters. */
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
85 return;
20054
8760c8681eac Remove the x264 option parser, and pass the options on to libx264 as a string instead. This provides automatic support for all current and future x264 options.
lorenm
parents: 19623
diff changeset
86
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
87 /* Step 1: look for initial preset/tune. */
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
88 copy = p = strdup(arg);
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
89 while ((name = strsep(&copy, ":"))) {
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
90 char *value = strpbrk(name, "=:");
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
91 if (!value)
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
92 continue;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
93 *value++ = 0;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
94 if (!strcasecmp(name, "preset"))
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
95 preset = value;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
96 else if (!strcasecmp(name, "tune"))
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
97 tune = value;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
98 }
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
99 if (x264_param_default_preset(&param, preset, tune) < 0) {
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
100 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option x264encopts: Invalid preset or tune.\n");
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
101 parse_error = 1;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
102 }
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
103 free(p);
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:
diff changeset
104
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
105 /* Step 2: explicit user overrides */
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
106 while ((name = strsep(&arg, ":")) && *name) {
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
107 int ret = 0;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
108 char *value = strpbrk(name, "=:");
20054
8760c8681eac Remove the x264 option parser, and pass the options on to libx264 as a string instead. This provides automatic support for all current and future x264 options.
lorenm
parents: 19623
diff changeset
109
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
110 if (value)
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
111 *value++ = 0;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
112 if (!strcasecmp(name, "profile"))
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
113 profile = value;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
114 else if (!strcasecmp(name, "turbo")) {
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
115 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option x264encopts: turbo option is deprecated; "
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
116 "use slow_firstpass to disable turbo\n");
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
117 if (value && *value == '0')
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
118 slow_firstpass = 1;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
119 } else if (!strcasecmp(name, "slow_firstpass"))
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
120 slow_firstpass = 1;
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
121 else if (strcasecmp(name, "preset") && strcasecmp(name, "tune")) {
31299
34507085a841 Cosmetics: properly indent block after introducing if statement in r31363.
tack
parents: 31297
diff changeset
122 ret = x264_param_parse(&param, name, value);
34507085a841 Cosmetics: properly indent block after introducing if statement in r31363.
tack
parents: 31297
diff changeset
123 if (ret == X264_PARAM_BAD_NAME)
34507085a841 Cosmetics: properly indent block after introducing if statement in r31363.
tack
parents: 31297
diff changeset
124 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option x264encopts: Unknown suboption %s\n", name);
34507085a841 Cosmetics: properly indent block after introducing if statement in r31363.
tack
parents: 31297
diff changeset
125 if (ret == X264_PARAM_BAD_VALUE)
34507085a841 Cosmetics: properly indent block after introducing if statement in r31363.
tack
parents: 31297
diff changeset
126 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option x264encopts: Bad argument %s=%s\n",
34507085a841 Cosmetics: properly indent block after introducing if statement in r31363.
tack
parents: 31297
diff changeset
127 name, value ? value : "(null)");
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
128
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
129 }
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
130 /* mark this option as done, so it's not reparsed if there's another -x264encopts */
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
131 *name = 0;
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
132
20317
50584bb892c0 make any parse error in -x264encopts fatal
lorenm
parents: 20297
diff changeset
133 parse_error |= ret;
16366
e054a3c93a26 custom quantization matrix for x264, original patch by Robert Swain < robert POUM swain AH gmail POUM com>
gpoirier
parents: 16016
diff changeset
134 }
e054a3c93a26 custom quantization matrix for x264, original patch by Robert Swain < robert POUM swain AH gmail POUM com>
gpoirier
parents: 16016
diff changeset
135
31297
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
136 /* Step 3: Apply fast first pass (turbo) options. */
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
137 if (!slow_firstpass)
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
138 x264_param_apply_fastfirstpass(&param);
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
139
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
140 /* Step 4: enforce profile */
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
141 if (profile && x264_param_apply_profile(&param, profile) < 0)
97c3077b4e67 ve_x264: rewrite option parsing and add support for x264's presets,
tack
parents: 31007
diff changeset
142 parse_error = 1;
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
143 }
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
144
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
145 static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) {
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
146 h264_module_t *mod=(h264_module_t*)vf->priv;
20317
50584bb892c0 make any parse error in -x264encopts fatal
lorenm
parents: 20297
diff changeset
147
50584bb892c0 make any parse error in -x264encopts fatal
lorenm
parents: 20297
diff changeset
148 if(parse_error)
50584bb892c0 make any parse error in -x264encopts fatal
lorenm
parents: 20297
diff changeset
149 return 0;
50584bb892c0 make any parse error in -x264encopts fatal
lorenm
parents: 20297
diff changeset
150
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
151 mod->mux->bih->biWidth = width;
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
152 mod->mux->bih->biHeight = height;
25570
b7ab557b7b30 remove code for colorspaces x264 doesn't support
lorenm
parents: 25232
diff changeset
153 mod->mux->bih->biSizeImage = width * height * 3;
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
154 mod->mux->aspect = (float)d_width/d_height;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26754
diff changeset
155
20333
7f84082900a3 Add a call to x264enc_set_param in config, otherwise mencoder -ovc x264
reimar
parents: 20317
diff changeset
156 // make sure param is initialized
7f84082900a3 Add a call to x264enc_set_param in config, otherwise mencoder -ovc x264
reimar
parents: 20317
diff changeset
157 x264enc_set_param(NULL, "");
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
158 param.i_width = width;
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
159 param.i_height = height;
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
160 param.i_fps_num = mod->mux->h.dwRate;
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
161 param.i_fps_den = mod->mux->h.dwScale;
31007
26537f75c1dd Tell x264 that we aren't going to give it timestamps.
lorenm
parents: 30949
diff changeset
162 param.b_vfr_input = 0;
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
163 param.vui.i_sar_width = d_width*height;
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
164 param.vui.i_sar_height = d_height*width;
15964
d244178a3105 x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents: 15744
diff changeset
165
20297
b69c85b29cb5 make -passlogfile work with x264 again (broke in r20060)
lorenm
parents: 20252
diff changeset
166 x264_param_parse(&param, "stats", passtmpfile);
b69c85b29cb5 make -passlogfile work with x264 again (broke in r20060)
lorenm
parents: 20252
diff changeset
167
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:
diff changeset
168 switch(outfmt) {
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:
diff changeset
169 case IMGFMT_I420:
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
170 param.i_csp = X264_CSP_I420;
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:
diff changeset
171 break;
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:
diff changeset
172 case IMGFMT_YV12:
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
173 param.i_csp = X264_CSP_YV12;
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:
diff changeset
174 break;
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:
diff changeset
175 default:
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:
diff changeset
176 mp_msg(MSGT_MENCODER, MSGL_ERR, "Wrong colorspace.\n");
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:
diff changeset
177 return 0;
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:
diff changeset
178 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26754
diff changeset
179
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
180 mod->x264 = x264_encoder_open(&param);
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:
diff changeset
181 if(!mod->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:
diff changeset
182 mp_msg(MSGT_MENCODER, MSGL_ERR, "x264_encoder_open failed.\n");
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:
diff changeset
183 return 0;
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:
diff changeset
184 }
19577
7e19b1207b81 "global header" support, this is pretty much just copy and pasted code from
michael
parents: 19125
diff changeset
185
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
186 if(!param.b_repeat_headers){
19577
7e19b1207b81 "global header" support, this is pretty much just copy and pasted code from
michael
parents: 19125
diff changeset
187 x264_nal_t *nal;
29662
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
188 int extradata_size, nnal;
19577
7e19b1207b81 "global header" support, this is pretty much just copy and pasted code from
michael
parents: 19125
diff changeset
189
29662
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
190 extradata_size = x264_encoder_headers(mod->x264, &nal, &nnal);
19577
7e19b1207b81 "global header" support, this is pretty much just copy and pasted code from
michael
parents: 19125
diff changeset
191
32123
a86413775fbe Replace sizeof(BITMAPINFOHEADER)
reimar
parents: 32122
diff changeset
192 mod->mux->bih= realloc(mod->mux->bih, sizeof(*mod->mux->bih) + extradata_size);
29662
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
193 memcpy(mod->mux->bih + 1, nal->p_payload, extradata_size);
32123
a86413775fbe Replace sizeof(BITMAPINFOHEADER)
reimar
parents: 32122
diff changeset
194 mod->mux->bih->biSize= sizeof(*mod->mux->bih) + extradata_size;
19577
7e19b1207b81 "global header" support, this is pretty much just copy and pasted code from
michael
parents: 19125
diff changeset
195 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26754
diff changeset
196
29745
58e73accaeb7 sync to x264-r1296
lorenm
parents: 29663
diff changeset
197 if (param.i_bframe > 1 && param.i_bframe_pyramid)
17659
92ac78a93625 Fix video delay when encoding with B-frames.
corey
parents: 17523
diff changeset
198 mod->mux->decoder_delay = 2;
92ac78a93625 Fix video delay when encoding with B-frames.
corey
parents: 17523
diff changeset
199 else
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
200 mod->mux->decoder_delay = param.i_bframe ? 1 : 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26754
diff changeset
201
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:
diff changeset
202 return 1;
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:
diff changeset
203 }
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:
diff changeset
204
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
205 static int control(struct vf_instance *vf, int request, void *data)
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:
diff changeset
206 {
20054
8760c8681eac Remove the x264 option parser, and pass the options on to libx264 as a string instead. This provides automatic support for all current and future x264 options.
lorenm
parents: 19623
diff changeset
207 h264_module_t *mod=(h264_module_t*)vf->priv;
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
208 switch(request){
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
209 case VFCTRL_FLUSH_FRAMES:
29663
18b540567d56 Use x264_encoder_delayed_frames instead of the current hack to flush delayed
reimar
parents: 29662
diff changeset
210 while (x264_encoder_delayed_frames(mod->x264) > 0)
18b540567d56 Use x264_encoder_delayed_frames instead of the current hack to flush delayed
reimar
parents: 29662
diff changeset
211 encode_frame(vf, NULL);
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
212 return CONTROL_TRUE;
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
213 default:
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
214 return CONTROL_UNKNOWN;
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
215 }
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:
diff changeset
216 }
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:
diff changeset
217
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
218 static int query_format(struct vf_instance *vf, unsigned int fmt)
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:
diff changeset
219 {
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:
diff changeset
220 switch(fmt) {
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:
diff changeset
221 case IMGFMT_I420:
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 26647
diff changeset
222 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
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:
diff changeset
223 case IMGFMT_YV12:
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:
diff changeset
224 case IMGFMT_422P:
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:
diff changeset
225 case IMGFMT_444P:
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:
diff changeset
226 case IMGFMT_YVYU:
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:
diff changeset
227 case IMGFMT_RGB:
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:
diff changeset
228 case IMGFMT_BGR:
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:
diff changeset
229 case IMGFMT_BGR32:
14943
4f43e3452b36 sync to x264 171: chroma_me, chroma_qp_offset
lorenm
parents: 14916
diff changeset
230 /* These colorspaces are supported, but they'll just have
4f43e3452b36 sync to x264 171: chroma_me, chroma_qp_offset
lorenm
parents: 14916
diff changeset
231 * to be converted to I420 internally */
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:
diff changeset
232 return 0; /* VFCAP_CSP_SUPPORTED */
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:
diff changeset
233 }
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:
diff changeset
234 return 0;
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:
diff changeset
235 }
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:
diff changeset
236
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
237 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
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:
diff changeset
238 {
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:
diff changeset
239 h264_module_t *mod=(h264_module_t*)vf->priv;
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:
diff changeset
240 int i;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26754
diff changeset
241
32527
babddccb9312 use x264_picture_init.
lorenm
parents: 32478
diff changeset
242 x264_picture_init(&mod->pic);
20252
eaaf13b39595 fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents: 20054
diff changeset
243 mod->pic.img.i_csp=param.i_csp;
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:
diff changeset
244 mod->pic.img.i_plane=3;
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:
diff changeset
245 for(i=0; i<4; i++) {
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:
diff changeset
246 mod->pic.img.plane[i] = mpi->planes[i];
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:
diff changeset
247 mod->pic.img.i_stride[i] = mpi->stride[i];
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:
diff changeset
248 }
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:
diff changeset
249
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:
diff changeset
250 mod->pic.i_type = X264_TYPE_AUTO;
32478
87870a8a114a Support for -force-key-frames for ve_x264.
cigaes
parents: 32123
diff changeset
251 if (is_forced_key_frame(pts))
87870a8a114a Support for -force-key-frames for ve_x264.
cigaes
parents: 32123
diff changeset
252 mod->pic.i_type = X264_TYPE_KEYFRAME;
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
253
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
254 return encode_frame(vf, &mod->pic) >= 0;
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
255 }
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
256
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
257 static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in)
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
258 {
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
259 h264_module_t *mod=(h264_module_t*)vf->priv;
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
260 x264_picture_t pic_out;
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
261 x264_nal_t *nal;
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
262 int i_nal;
29662
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
263 int i_size;
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
264
29662
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
265 i_size = x264_encoder_encode(mod->x264, &nal, &i_nal, pic_in, &pic_out);
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
266
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
267 if(i_size<0) {
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:
diff changeset
268 mp_msg(MSGT_MENCODER, MSGL_ERR, "x264_encoder_encode failed\n");
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
269 return -1;
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:
diff changeset
270 }
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:
diff changeset
271 if(i_size>0) {
30748
923f55aafcf6 Reuse the keyframe flag from x264 instead of trying to derive it on our own.
reimar
parents: 30747
diff changeset
272 int keyframe = pic_out.b_keyframe;
29662
fb0202969d92 sync to x264-r1260 (which changed api)
lorenm
parents: 29438
diff changeset
273 memcpy(mod->mux->buffer, nal->p_payload, i_size);
30747
7ac542b9ca24 Use the KEYFRAME define instead of some magic number.
reimar
parents: 30642
diff changeset
274 muxer_write_chunk(mod->mux, i_size, keyframe?AVIIF_KEYFRAME:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
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:
diff changeset
275 }
17659
92ac78a93625 Fix video delay when encoding with B-frames.
corey
parents: 17523
diff changeset
276 else
92ac78a93625 Fix video delay when encoding with B-frames.
corey
parents: 17523
diff changeset
277 ++mod->mux->encoder_delay;
14784
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
278
53d306774ce2 sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents: 14759
diff changeset
279 return i_size;
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:
diff changeset
280 }
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:
diff changeset
281
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 29745
diff changeset
282 static void uninit(struct vf_instance *vf)
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:
diff changeset
283 {
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:
diff changeset
284 h264_module_t *mod=(h264_module_t*)vf->priv;
22158
a6a93224cf4d Avoid crash when uninit is called without ever calling config in x264 encoder
reimar
parents: 22032
diff changeset
285 if (mod->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:
diff changeset
286 x264_encoder_close(mod->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:
diff changeset
287 }
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:
diff changeset
288
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:
diff changeset
289 static int vf_open(vf_instance_t *vf, char *args) {
13334
04f7b5e75785 fix compile on gcc 2.95.3
iive
parents: 13325
diff changeset
290 h264_module_t *mod;
04f7b5e75785 fix compile on gcc 2.95.3
iive
parents: 13325
diff changeset
291
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:
diff changeset
292 vf->config = config;
14878
5723c4b2a2ea fixes for encoding of multiple files
henry
parents: 14846
diff changeset
293 vf->default_caps = VFCAP_CONSTANT;
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:
diff changeset
294 vf->control = control;
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:
diff changeset
295 vf->query_format = query_format;
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:
diff changeset
296 vf->put_image = put_image;
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:
diff changeset
297 vf->uninit = uninit;
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:
diff changeset
298 vf->priv = malloc(sizeof(h264_module_t));
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:
diff changeset
299
13334
04f7b5e75785 fix compile on gcc 2.95.3
iive
parents: 13325
diff changeset
300 mod=(h264_module_t*)vf->priv;
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:
diff changeset
301 mod->mux = (muxer_stream_t*)args;
32123
a86413775fbe Replace sizeof(BITMAPINFOHEADER)
reimar
parents: 32122
diff changeset
302 mod->mux->bih = calloc(1, sizeof(*mod->mux->bih));
a86413775fbe Replace sizeof(BITMAPINFOHEADER)
reimar
parents: 32122
diff changeset
303 mod->mux->bih->biSize = sizeof(*mod->mux->bih);
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:
diff changeset
304 mod->mux->bih->biPlanes = 1;
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:
diff changeset
305 mod->mux->bih->biBitCount = 24;
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:
diff changeset
306 mod->mux->bih->biCompression = mmioFOURCC('h', '2', '6', '4');
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:
diff changeset
307
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:
diff changeset
308 return 1;
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:
diff changeset
309 }
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:
diff changeset
310
32033
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 31299
diff changeset
311 const vf_info_t ve_info_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:
diff changeset
312 "H.264 encoder",
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:
diff changeset
313 "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:
diff changeset
314 "Bernhard Rosenkraenzer <bero@arklinux.org>",
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:
diff changeset
315 "(C) 2004 LINUX4MEDIA GmbH; (C) 2004 Ark Linux",
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:
diff changeset
316 vf_open
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:
diff changeset
317 };