Merge "vpxenc: Add vpxenc.h and move/rename the global_config struct"
This commit is contained in:
		@@ -37,7 +37,7 @@ vpxdec.SRCS                 += $(LIBYUV_SRCS)
 | 
				
			|||||||
vpxdec.GUID                  = BA5FE66F-38DD-E034-F542-B1578C5FB950
 | 
					vpxdec.GUID                  = BA5FE66F-38DD-E034-F542-B1578C5FB950
 | 
				
			||||||
vpxdec.DESCRIPTION           = Full featured decoder
 | 
					vpxdec.DESCRIPTION           = Full featured decoder
 | 
				
			||||||
UTILS-$(CONFIG_ENCODERS)    += vpxenc.c
 | 
					UTILS-$(CONFIG_ENCODERS)    += vpxenc.c
 | 
				
			||||||
vpxenc.SRCS                 += args.c args.h y4minput.c y4minput.h
 | 
					vpxenc.SRCS                 += args.c args.h y4minput.c y4minput.h vpxenc.h
 | 
				
			||||||
vpxenc.SRCS                 += ivfdec.c ivfdec.h
 | 
					vpxenc.SRCS                 += ivfdec.c ivfdec.h
 | 
				
			||||||
vpxenc.SRCS                 += ivfenc.c ivfenc.h
 | 
					vpxenc.SRCS                 += ivfenc.c ivfenc.h
 | 
				
			||||||
vpxenc.SRCS                 += tools_common.c tools_common.h
 | 
					vpxenc.SRCS                 += tools_common.c tools_common.h
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										55
									
								
								vpxenc.c
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								vpxenc.c
									
									
									
									
									
								
							@@ -8,6 +8,7 @@
 | 
				
			|||||||
 *  be found in the AUTHORS file in the root of the source tree.
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "./vpxenc.h"
 | 
				
			||||||
#include "./vpx_config.h"
 | 
					#include "./vpx_config.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
@@ -214,11 +215,7 @@ static const arg_def_t verbosearg       = ARG_DEF("v", "verbose", 0,
 | 
				
			|||||||
                                                  "Show encoder parameters");
 | 
					                                                  "Show encoder parameters");
 | 
				
			||||||
static const arg_def_t psnrarg          = ARG_DEF(NULL, "psnr", 0,
 | 
					static const arg_def_t psnrarg          = ARG_DEF(NULL, "psnr", 0,
 | 
				
			||||||
                                                  "Show PSNR in status line");
 | 
					                                                  "Show PSNR in status line");
 | 
				
			||||||
enum TestDecodeFatality {
 | 
					
 | 
				
			||||||
  TEST_DECODE_OFF,
 | 
					 | 
				
			||||||
  TEST_DECODE_FATAL,
 | 
					 | 
				
			||||||
  TEST_DECODE_WARN,
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
static const struct arg_enum_list test_decode_enum[] = {
 | 
					static const struct arg_enum_list test_decode_enum[] = {
 | 
				
			||||||
  {"off",   TEST_DECODE_OFF},
 | 
					  {"off",   TEST_DECODE_OFF},
 | 
				
			||||||
  {"fatal", TEST_DECODE_FATAL},
 | 
					  {"fatal", TEST_DECODE_FATAL},
 | 
				
			||||||
@@ -861,30 +858,6 @@ static int compare_img(vpx_image_t *img1, vpx_image_t *img2)
 | 
				
			|||||||
                             NELEMENTS(vp9_arg_ctrl_map))
 | 
					                             NELEMENTS(vp9_arg_ctrl_map))
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Configuration elements common to all streams */
 | 
					 | 
				
			||||||
struct global_config {
 | 
					 | 
				
			||||||
  const struct codec_item  *codec;
 | 
					 | 
				
			||||||
  int                       passes;
 | 
					 | 
				
			||||||
  int                       pass;
 | 
					 | 
				
			||||||
  int                       usage;
 | 
					 | 
				
			||||||
  int                       deadline;
 | 
					 | 
				
			||||||
  int                       use_i420;
 | 
					 | 
				
			||||||
  int                       quiet;
 | 
					 | 
				
			||||||
  int                       verbose;
 | 
					 | 
				
			||||||
  int                       limit;
 | 
					 | 
				
			||||||
  int                       skip_frames;
 | 
					 | 
				
			||||||
  int                       show_psnr;
 | 
					 | 
				
			||||||
  enum TestDecodeFatality   test_decode;
 | 
					 | 
				
			||||||
  int                       have_framerate;
 | 
					 | 
				
			||||||
  struct vpx_rational       framerate;
 | 
					 | 
				
			||||||
  int                       out_part;
 | 
					 | 
				
			||||||
  int                       debug;
 | 
					 | 
				
			||||||
  int                       show_q_hist_buckets;
 | 
					 | 
				
			||||||
  int                       show_rate_hist_buckets;
 | 
					 | 
				
			||||||
  int                       disable_warnings;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Per-stream configuration */
 | 
					/* Per-stream configuration */
 | 
				
			||||||
struct stream_config {
 | 
					struct stream_config {
 | 
				
			||||||
  struct vpx_codec_enc_cfg  cfg;
 | 
					  struct vpx_codec_enc_cfg  cfg;
 | 
				
			||||||
@@ -937,7 +910,7 @@ void validate_positive_rational(const char          *msg,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void parse_global_config(struct global_config *global, char **argv) {
 | 
					static void parse_global_config(struct VpxEncoderConfig *global, char **argv) {
 | 
				
			||||||
  char       **argi, **argj;
 | 
					  char       **argi, **argj;
 | 
				
			||||||
  struct arg   arg;
 | 
					  struct arg   arg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1088,7 +1061,7 @@ static void close_input_file(struct VpxInputContext *input) {
 | 
				
			|||||||
    y4m_input_close(&input->y4m);
 | 
					    y4m_input_close(&input->y4m);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct stream_state *new_stream(struct global_config *global,
 | 
					static struct stream_state *new_stream(struct VpxEncoderConfig *global,
 | 
				
			||||||
                                       struct stream_state *prev) {
 | 
					                                       struct stream_state *prev) {
 | 
				
			||||||
  struct stream_state *stream;
 | 
					  struct stream_state *stream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1137,7 +1110,7 @@ static struct stream_state *new_stream(struct global_config *global,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int parse_stream_params(struct global_config *global,
 | 
					static int parse_stream_params(struct VpxEncoderConfig *global,
 | 
				
			||||||
                               struct stream_state  *stream,
 | 
					                               struct stream_state  *stream,
 | 
				
			||||||
                               char **argv) {
 | 
					                               char **argv) {
 | 
				
			||||||
  char                   **argi, **argj;
 | 
					  char                   **argi, **argj;
 | 
				
			||||||
@@ -1342,7 +1315,7 @@ static void set_stream_dimensions(struct stream_state *stream,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_default_kf_interval(struct stream_state *stream,
 | 
					static void set_default_kf_interval(struct stream_state *stream,
 | 
				
			||||||
                                    struct global_config *global) {
 | 
					                                    struct VpxEncoderConfig *global) {
 | 
				
			||||||
  /* Use a max keyframe interval of 5 seconds, if none was
 | 
					  /* Use a max keyframe interval of 5 seconds, if none was
 | 
				
			||||||
   * specified on the command line.
 | 
					   * specified on the command line.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
@@ -1355,7 +1328,7 @@ static void set_default_kf_interval(struct stream_state  *stream,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void show_stream_config(struct stream_state *stream,
 | 
					static void show_stream_config(struct stream_state *stream,
 | 
				
			||||||
                               struct global_config *global,
 | 
					                               struct VpxEncoderConfig *global,
 | 
				
			||||||
                               struct VpxInputContext *input) {
 | 
					                               struct VpxInputContext *input) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SHOW(field) \
 | 
					#define SHOW(field) \
 | 
				
			||||||
@@ -1405,7 +1378,7 @@ static void show_stream_config(struct stream_state  *stream,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void open_output_file(struct stream_state *stream,
 | 
					static void open_output_file(struct stream_state *stream,
 | 
				
			||||||
                             struct global_config *global) {
 | 
					                             struct VpxEncoderConfig *global) {
 | 
				
			||||||
  const char *fn = stream->config.out_fn;
 | 
					  const char *fn = stream->config.out_fn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  stream->file = strcmp(fn, "-") ? fopen(fn, "wb") : set_binary_mode(stdout);
 | 
					  stream->file = strcmp(fn, "-") ? fopen(fn, "wb") : set_binary_mode(stdout);
 | 
				
			||||||
@@ -1446,7 +1419,7 @@ static void close_output_file(struct stream_state *stream,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void setup_pass(struct stream_state *stream,
 | 
					static void setup_pass(struct stream_state *stream,
 | 
				
			||||||
                       struct global_config *global,
 | 
					                       struct VpxEncoderConfig *global,
 | 
				
			||||||
                       int pass) {
 | 
					                       int pass) {
 | 
				
			||||||
  if (stream->config.stats_fn) {
 | 
					  if (stream->config.stats_fn) {
 | 
				
			||||||
    if (!stats_open_file(&stream->stats, stream->config.stats_fn,
 | 
					    if (!stats_open_file(&stream->stats, stream->config.stats_fn,
 | 
				
			||||||
@@ -1470,7 +1443,7 @@ static void setup_pass(struct stream_state  *stream,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void initialize_encoder(struct stream_state *stream,
 | 
					static void initialize_encoder(struct stream_state *stream,
 | 
				
			||||||
                               struct global_config *global) {
 | 
					                               struct VpxEncoderConfig *global) {
 | 
				
			||||||
  int i;
 | 
					  int i;
 | 
				
			||||||
  int flags = 0;
 | 
					  int flags = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1505,7 +1478,7 @@ static void initialize_encoder(struct stream_state  *stream,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void encode_frame(struct stream_state *stream,
 | 
					static void encode_frame(struct stream_state *stream,
 | 
				
			||||||
                         struct global_config *global,
 | 
					                         struct VpxEncoderConfig *global,
 | 
				
			||||||
                         struct vpx_image *img,
 | 
					                         struct vpx_image *img,
 | 
				
			||||||
                         unsigned int frames_in) {
 | 
					                         unsigned int frames_in) {
 | 
				
			||||||
  vpx_codec_pts_t frame_start, next_frame_start;
 | 
					  vpx_codec_pts_t frame_start, next_frame_start;
 | 
				
			||||||
@@ -1563,7 +1536,7 @@ static void update_quantizer_histogram(struct stream_state *stream) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void get_cx_data(struct stream_state *stream,
 | 
					static void get_cx_data(struct stream_state *stream,
 | 
				
			||||||
                        struct global_config *global,
 | 
					                        struct VpxEncoderConfig *global,
 | 
				
			||||||
                        int *got_data) {
 | 
					                        int *got_data) {
 | 
				
			||||||
  const vpx_codec_cx_pkt_t *pkt;
 | 
					  const vpx_codec_cx_pkt_t *pkt;
 | 
				
			||||||
  const struct vpx_codec_enc_cfg *cfg = &stream->config.cfg;
 | 
					  const struct vpx_codec_enc_cfg *cfg = &stream->config.cfg;
 | 
				
			||||||
@@ -1763,7 +1736,7 @@ int continue_prompt() {
 | 
				
			|||||||
  return c == 'y';
 | 
					  return c == 'y';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void check_quantizer(struct global_config* config, int min_q, int max_q) {
 | 
					void check_quantizer(struct VpxEncoderConfig* config, int min_q, int max_q) {
 | 
				
			||||||
  int check_failed = 0;
 | 
					  int check_failed = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (config->disable_warnings)
 | 
					  if (config->disable_warnings)
 | 
				
			||||||
@@ -1788,7 +1761,7 @@ int main(int argc, const char **argv_) {
 | 
				
			|||||||
  int frame_avail, got_data;
 | 
					  int frame_avail, got_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  struct VpxInputContext input = {0};
 | 
					  struct VpxInputContext input = {0};
 | 
				
			||||||
  struct global_config global;
 | 
					  struct VpxEncoderConfig global;
 | 
				
			||||||
  struct stream_state *streams = NULL;
 | 
					  struct stream_state *streams = NULL;
 | 
				
			||||||
  char **argv, **argi;
 | 
					  char **argv, **argi;
 | 
				
			||||||
  uint64_t cx_time = 0;
 | 
					  uint64_t cx_time = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										45
									
								
								vpxenc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vpxenc.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 *  Copyright (c) 2013 The WebM project authors. All Rights Reserved.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  Use of this source code is governed by a BSD-style license
 | 
				
			||||||
 | 
					 *  that can be found in the LICENSE file in the root of the source
 | 
				
			||||||
 | 
					 *  tree. An additional intellectual property rights grant can be found
 | 
				
			||||||
 | 
					 *  in the file PATENTS.  All contributing project authors may
 | 
				
			||||||
 | 
					 *  be found in the AUTHORS file in the root of the source tree.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#ifndef VPXENC_H_
 | 
				
			||||||
 | 
					#define VPXENC_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "vpx/vpx_encoder.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum TestDecodeFatality {
 | 
				
			||||||
 | 
					  TEST_DECODE_OFF,
 | 
				
			||||||
 | 
					  TEST_DECODE_FATAL,
 | 
				
			||||||
 | 
					  TEST_DECODE_WARN,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Configuration elements common to all streams. */
 | 
				
			||||||
 | 
					struct VpxEncoderConfig {
 | 
				
			||||||
 | 
					  const struct codec_item *codec;
 | 
				
			||||||
 | 
					  int passes;
 | 
				
			||||||
 | 
					  int pass;
 | 
				
			||||||
 | 
					  int usage;
 | 
				
			||||||
 | 
					  int deadline;
 | 
				
			||||||
 | 
					  int use_i420;
 | 
				
			||||||
 | 
					  int quiet;
 | 
				
			||||||
 | 
					  int verbose;
 | 
				
			||||||
 | 
					  int limit;
 | 
				
			||||||
 | 
					  int skip_frames;
 | 
				
			||||||
 | 
					  int show_psnr;
 | 
				
			||||||
 | 
					  enum TestDecodeFatality test_decode;
 | 
				
			||||||
 | 
					  int have_framerate;
 | 
				
			||||||
 | 
					  struct vpx_rational framerate;
 | 
				
			||||||
 | 
					  int out_part;
 | 
				
			||||||
 | 
					  int debug;
 | 
				
			||||||
 | 
					  int show_q_hist_buckets;
 | 
				
			||||||
 | 
					  int show_rate_hist_buckets;
 | 
				
			||||||
 | 
					  int disable_warnings;
 | 
				
			||||||
 | 
					  int disable_warning_prompt;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // VPXENC_H_
 | 
				
			||||||
		Reference in New Issue
	
	Block a user