Mercurial > mplayer.hg
annotate libmpcodecs/ve_x264.c @ 30777:079be31079d3
Add a VCD support for OS/2
author | komh |
---|---|
date | Wed, 03 Mar 2010 14:32:29 +0000 |
parents | 923f55aafcf6 |
children | e4c7703dd901 |
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 |
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
|
28 #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
|
29 #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
|
30 #include <string.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 <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
|
32 |
17012 | 33 #include "config.h" |
34 #include "mp_msg.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
|
35 |
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
|
36 #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
|
37 #include "codec-cfg.h" |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
22158
diff
changeset
|
38 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
39 #include "libmpdemux/demuxer.h" |
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
40 #include "libmpdemux/stheader.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
|
41 |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
22158
diff
changeset
|
42 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
43 #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
|
44 |
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
|
45 #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
|
46 #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
|
47 #include "vf.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
|
48 |
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 <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
|
50 |
25607
9d0b189ce1b2
Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents:
25570
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 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
|
55 } 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
|
56 |
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 extern char* passtmpfile; |
15964
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
58 static int turbo = 0; |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
59 static x264_param_t param; |
20317 | 60 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
|
61 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
62 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
|
63 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
|
64 |
25232
893db6cc97b2
Add appropriate const specifiers to some custom parse functions.
reimar
parents:
22601
diff
changeset
|
65 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
|
66 { |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
67 static int initted = 0; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
68 if(!initted) { |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
69 x264_param_default(¶m); |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
70 x264_param_parse(¶m, "psnr", "no"); |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
71 x264_param_parse(¶m, "ssim", "no"); |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
72 initted = 1; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
73 } |
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
|
74 |
22032
62d7b935df2e
fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents:
21660
diff
changeset
|
75 if(!arg) { |
62d7b935df2e
fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents:
21660
diff
changeset
|
76 parse_error = 1; |
62d7b935df2e
fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents:
21660
diff
changeset
|
77 return; |
62d7b935df2e
fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents:
21660
diff
changeset
|
78 } |
62d7b935df2e
fix a segfault if -x264encopts is the last commandline option (with no argument)
lorenm
parents:
21660
diff
changeset
|
79 |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
80 while(*arg) { |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
81 char *name = arg; |
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
|
82 char *value; |
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
|
83 int ret; |
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
|
84 |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
85 arg += strcspn(arg, ":"); |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
86 if(*arg) { |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
87 *arg = 0; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
88 arg++; |
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
|
89 } |
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
|
90 |
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
|
91 value = strchr( name, '=' ); |
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
|
92 if(value) { |
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
|
93 *value = 0; |
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
|
94 value++; |
16366
e054a3c93a26
custom quantization matrix for x264, original patch by Robert Swain < robert POUM swain AH gmail POUM com>
gpoirier
parents:
16016
diff
changeset
|
95 } |
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
|
96 |
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
|
97 if(!strcmp(name, "turbo")) { |
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
|
98 turbo = value ? atoi(value) : 1; |
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
|
99 continue; |
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
|
100 } |
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
|
101 |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
102 ret = x264_param_parse(¶m, name, value); |
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
|
103 if(ret == X264_PARAM_BAD_NAME) |
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
|
104 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option x264encopts: Unknown suboption %s\n", name); |
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
|
105 if(ret == X264_PARAM_BAD_VALUE) |
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
|
106 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option x264encopts: Bad argument %s=%s\n", name, value ? value : "(null)"); |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
107 |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
108 /* 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
|
109 *name = 0; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
110 |
20317 | 111 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
|
112 } |
e054a3c93a26
custom quantization matrix for x264, original patch by Robert Swain < robert POUM swain AH gmail POUM com>
gpoirier
parents:
16016
diff
changeset
|
113 |
20340
9d88396480bb
x264: don't enable turbo in the middle pass of a 3pass encode. (broke in r20060)
lorenm
parents:
20333
diff
changeset
|
114 if(param.rc.b_stat_write && !param.rc.b_stat_read) { |
15964
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
115 /* Adjust or disable some flags to gain speed in the first pass */ |
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
116 if(turbo == 1) |
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
117 { |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
118 param.i_frame_reference = ( param.i_frame_reference + 1 ) >> 1; |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
20340
diff
changeset
|
119 param.analyse.i_subpel_refine = FFMAX( FFMIN( 3, param.analyse.i_subpel_refine - 1 ), 1 ); |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
120 param.analyse.inter &= ( ~X264_ANALYSE_PSUB8x8 ); |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
121 param.analyse.inter &= ( ~X264_ANALYSE_BSUB16x16 ); |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
122 param.analyse.i_trellis = 0; |
15964
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
123 } |
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
|
124 else if(turbo >= 2) |
15964
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
125 { |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
126 param.i_frame_reference = 1; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
127 param.analyse.i_subpel_refine = 1; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
128 param.analyse.i_me_method = X264_ME_DIA; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
129 param.analyse.inter = 0; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
130 param.analyse.b_transform_8x8 = 0; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
131 param.analyse.b_weighted_bipred = 0; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
132 param.analyse.i_trellis = 0; |
15964
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
133 } |
d244178a3105
x264 fast first pass, patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15744
diff
changeset
|
134 } |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
135 } |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
136 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
137 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
|
138 h264_module_t *mod=(h264_module_t*)vf->priv; |
20317 | 139 |
140 if(parse_error) | |
141 return 0; | |
142 | |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
143 mod->mux->bih->biWidth = width; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
144 mod->mux->bih->biHeight = height; |
25570 | 145 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
|
146 mod->mux->aspect = (float)d_width/d_height; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26754
diff
changeset
|
147 |
20333
7f84082900a3
Add a call to x264enc_set_param in config, otherwise mencoder -ovc x264
reimar
parents:
20317
diff
changeset
|
148 // make sure param is initialized |
7f84082900a3
Add a call to x264enc_set_param in config, otherwise mencoder -ovc x264
reimar
parents:
20317
diff
changeset
|
149 x264enc_set_param(NULL, ""); |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
150 param.i_width = width; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
151 param.i_height = height; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
152 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
|
153 param.i_fps_den = mod->mux->h.dwScale; |
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
154 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
|
155 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
|
156 |
20297
b69c85b29cb5
make -passlogfile work with x264 again (broke in r20060)
lorenm
parents:
20252
diff
changeset
|
157 x264_param_parse(¶m, "stats", passtmpfile); |
b69c85b29cb5
make -passlogfile work with x264 again (broke in r20060)
lorenm
parents:
20252
diff
changeset
|
158 |
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
|
159 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
|
160 case IMGFMT_I420: |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
161 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
|
162 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
|
163 case IMGFMT_YV12: |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26754
diff
changeset
|
170 |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
171 mod->x264 = x264_encoder_open(¶m); |
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
|
172 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
|
173 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
|
174 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
|
175 } |
19577
7e19b1207b81
"global header" support, this is pretty much just copy and pasted code from
michael
parents:
19125
diff
changeset
|
176 |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
177 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
|
178 x264_nal_t *nal; |
29662 | 179 int extradata_size, nnal; |
19577
7e19b1207b81
"global header" support, this is pretty much just copy and pasted code from
michael
parents:
19125
diff
changeset
|
180 |
29662 | 181 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
|
182 |
7e19b1207b81
"global header" support, this is pretty much just copy and pasted code from
michael
parents:
19125
diff
changeset
|
183 mod->mux->bih= realloc(mod->mux->bih, sizeof(BITMAPINFOHEADER) + extradata_size); |
29662 | 184 memcpy(mod->mux->bih + 1, nal->p_payload, extradata_size); |
19577
7e19b1207b81
"global header" support, this is pretty much just copy and pasted code from
michael
parents:
19125
diff
changeset
|
185 mod->mux->bih->biSize= sizeof(BITMAPINFOHEADER) + extradata_size; |
7e19b1207b81
"global header" support, this is pretty much just copy and pasted code from
michael
parents:
19125
diff
changeset
|
186 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26754
diff
changeset
|
187 |
29745 | 188 if (param.i_bframe > 1 && param.i_bframe_pyramid) |
17659 | 189 mod->mux->decoder_delay = 2; |
190 else | |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
191 mod->mux->decoder_delay = param.i_bframe ? 1 : 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26754
diff
changeset
|
192 |
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
|
193 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
|
194 } |
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
|
195 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
196 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
|
197 { |
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
|
198 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
|
199 switch(request){ |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
200 case VFCTRL_FLUSH_FRAMES: |
29663
18b540567d56
Use x264_encoder_delayed_frames instead of the current hack to flush delayed
reimar
parents:
29662
diff
changeset
|
201 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
|
202 encode_frame(vf, NULL); |
14784
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
203 return CONTROL_TRUE; |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
204 default: |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
205 return CONTROL_UNKNOWN; |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
206 } |
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
|
207 } |
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
|
208 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
209 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
|
210 { |
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
|
211 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
|
212 case IMGFMT_I420: |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26647
diff
changeset
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 case IMGFMT_BGR32: |
14943 | 221 /* These colorspaces are supported, but they'll just have |
222 * 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
|
223 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
|
224 } |
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 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
|
226 } |
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 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
228 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
|
229 { |
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
|
230 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
|
231 int i; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26754
diff
changeset
|
232 |
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
|
233 memset(&mod->pic, 0, sizeof(x264_picture_t)); |
20252
eaaf13b39595
fix multiple instances of -x264encopts on the commandline (broke in r20060)
lorenm
parents:
20054
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 } |
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 |
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
|
241 mod->pic.i_type = X264_TYPE_AUTO; |
14784
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
242 |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
243 return encode_frame(vf, &mod->pic) >= 0; |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
244 } |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
245 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
246 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
|
247 { |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
248 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
|
249 x264_picture_t pic_out; |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
250 x264_nal_t *nal; |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
251 int i_nal; |
29662 | 252 int i_size; |
14784
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
253 |
29662 | 254 i_size = x264_encoder_encode(mod->x264, &nal, &i_nal, pic_in, &pic_out); |
255 | |
256 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
|
257 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
|
258 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
|
259 } |
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
|
260 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
|
261 int keyframe = pic_out.b_keyframe; |
29662 | 262 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
|
263 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
|
264 } |
17659 | 265 else |
266 ++mod->mux->encoder_delay; | |
14784
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
267 |
53d306774ce2
sync to x264 r137: adaptive B-frame decision, flush delayed frames.
lorenm
parents:
14759
diff
changeset
|
268 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
|
269 } |
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 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29745
diff
changeset
|
271 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
|
272 { |
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
|
273 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
|
274 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
|
275 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
|
276 } |
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
|
277 |
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
|
278 static int vf_open(vf_instance_t *vf, char *args) { |
13334 | 279 h264_module_t *mod; |
280 | |
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
|
281 vf->config = config; |
14878 | 282 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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 |
13334 | 289 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
|
290 mod->mux = (muxer_stream_t*)args; |
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
|
291 mod->mux->bih = malloc(sizeof(BITMAPINFOHEADER)); |
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 memset(mod->mux->bih, 0, sizeof(BITMAPINFOHEADER)); |
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
|
293 mod->mux->bih->biSize = sizeof(BITMAPINFOHEADER); |
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 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
|
295 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
|
296 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
|
297 |
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 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
|
299 } |
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
|
300 |
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 vf_info_t 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:
diff
changeset
|
302 "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
|
303 "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
|
304 "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
|
305 "(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
|
306 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
|
307 }; |