Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: source/patched-ffmpeg-mt/cmdutils.c

Issue 4533003: patched ffmpeg nov 2 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Various utilities for command line tools 2 * Various utilities for command line tools
3 * Copyright (c) 2000-2003 Fabrice Bellard 3 * Copyright (c) 2000-2003 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 14 matching lines...) Expand all
25 #include <math.h> 25 #include <math.h>
26 26
27 /* Include only the enabled headers since some compilers (namely, Sun 27 /* Include only the enabled headers since some compilers (namely, Sun
28 Studio) will not omit unused inline functions and create undefined 28 Studio) will not omit unused inline functions and create undefined
29 references to libraries that are not being built. */ 29 references to libraries that are not being built. */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "libavformat/avformat.h" 32 #include "libavformat/avformat.h"
33 #include "libavfilter/avfilter.h" 33 #include "libavfilter/avfilter.h"
34 #include "libavdevice/avdevice.h" 34 #include "libavdevice/avdevice.h"
35 #if CONFIG_SWSCALE
35 #include "libswscale/swscale.h" 36 #include "libswscale/swscale.h"
37 #endif
36 #include "libpostproc/postprocess.h" 38 #include "libpostproc/postprocess.h"
37 #include "libavutil/avstring.h" 39 #include "libavutil/avstring.h"
38 #include "libavutil/pixdesc.h" 40 #include "libavutil/pixdesc.h"
39 #include "libavutil/eval.h" 41 #include "libavutil/eval.h"
40 #include "libavcodec/opt.h" 42 #include "libavcodec/opt.h"
41 #include "libavcore/avcore.h" 43 #include "libavcore/avcore.h"
42 #include "cmdutils.h" 44 #include "cmdutils.h"
43 #include "version.h" 45 #include "version.h"
44 #if CONFIG_NETWORK 46 #if CONFIG_NETWORK
45 #include "libavformat/network.h" 47 #include "libavformat/network.h"
46 #endif 48 #endif
47 #if HAVE_SYS_RESOURCE_H 49 #if HAVE_SYS_RESOURCE_H
48 #include <sys/resource.h> 50 #include <sys/resource.h>
49 #endif 51 #endif
50 52
51 const char **opt_names; 53 const char **opt_names;
52 const char **opt_values; 54 const char **opt_values;
53 static int opt_name_count; 55 static int opt_name_count;
54 AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; 56 AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
55 AVFormatContext *avformat_opts; 57 AVFormatContext *avformat_opts;
58 #if CONFIG_SWSCALE
56 struct SwsContext *sws_opts; 59 struct SwsContext *sws_opts;
60 #endif
57 61
58 const int this_year = 2010; 62 const int this_year = 2010;
59 63
60 void init_opts(void) 64 void init_opts(void)
61 { 65 {
62 int i; 66 int i;
63 for (i = 0; i < AVMEDIA_TYPE_NB; i++) 67 for (i = 0; i < AVMEDIA_TYPE_NB; i++)
64 avcodec_opts[i] = avcodec_alloc_context2(i); 68 avcodec_opts[i] = avcodec_alloc_context2(i);
65 avformat_opts = avformat_alloc_context(); 69 avformat_opts = avformat_alloc_context();
70 #if CONFIG_SWSCALE
66 sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NUL L); 71 sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NUL L);
72 #endif
67 } 73 }
68 74
69 void uninit_opts(void) 75 void uninit_opts(void)
70 { 76 {
71 int i; 77 int i;
72 for (i = 0; i < AVMEDIA_TYPE_NB; i++) 78 for (i = 0; i < AVMEDIA_TYPE_NB; i++)
73 av_freep(&avcodec_opts[i]); 79 av_freep(&avcodec_opts[i]);
74 av_freep(&avformat_opts->key); 80 av_freep(&avformat_opts->key);
75 av_freep(&avformat_opts); 81 av_freep(&avformat_opts);
82 #if CONFIG_SWSCALE
76 av_freep(&sws_opts); 83 av_freep(&sws_opts);
84 #endif
77 } 85 }
78 86
79 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl) 87 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
80 { 88 {
81 vfprintf(stdout, fmt, vl); 89 vfprintf(stdout, fmt, vl);
82 } 90 }
83 91
84 double parse_number_or_die(const char *context, const char *numstr, int type, do uble min, double max) 92 double parse_number_or_die(const char *context, const char *numstr, int type, do uble min, double max)
85 { 93 {
86 char *tail; 94 char *tail;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const AVOption *o= NULL; 226 const AVOption *o= NULL;
219 int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT _FLAG_SUBTITLE_PARAM, 0}; 227 int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT _FLAG_SUBTITLE_PARAM, 0};
220 228
221 for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){ 229 for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){
222 const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[t ype], opt_types[type]); 230 const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[t ype], opt_types[type]);
223 if(o2) 231 if(o2)
224 ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); 232 ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
225 } 233 }
226 if(!o && avformat_opts) 234 if(!o && avformat_opts)
227 ret = av_set_string3(avformat_opts, opt, arg, 1, &o); 235 ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
236 #if CONFIG_SWSCALE
228 if(!o && sws_opts) 237 if(!o && sws_opts)
229 ret = av_set_string3(sws_opts, opt, arg, 1, &o); 238 ret = av_set_string3(sws_opts, opt, arg, 1, &o);
239 #endif
230 if(!o){ 240 if(!o){
231 if(opt[0] == 'a') 241 if(opt[0] == 'a')
232 ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1 , &o); 242 ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1 , &o);
233 else if(opt[0] == 'v') 243 else if(opt[0] == 'v')
234 ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1 , &o); 244 ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1 , &o);
235 else if(opt[0] == 's') 245 else if(opt[0] == 's')
236 ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg , 1, &o); 246 ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg , 1, &o);
237 } 247 }
238 if (o && ret < 0) { 248 if (o && ret < 0) {
239 fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); 249 fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } \ 393 } \
384 394
385 static void print_all_libs_info(FILE* outstream, int flags) 395 static void print_all_libs_info(FILE* outstream, int flags)
386 { 396 {
387 PRINT_LIB_INFO(outstream, avutil, AVUTIL, flags); 397 PRINT_LIB_INFO(outstream, avutil, AVUTIL, flags);
388 PRINT_LIB_INFO(outstream, avcore, AVCORE, flags); 398 PRINT_LIB_INFO(outstream, avcore, AVCORE, flags);
389 PRINT_LIB_INFO(outstream, avcodec, AVCODEC, flags); 399 PRINT_LIB_INFO(outstream, avcodec, AVCODEC, flags);
390 PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags); 400 PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags);
391 PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags); 401 PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags);
392 PRINT_LIB_INFO(outstream, avfilter, AVFILTER, flags); 402 PRINT_LIB_INFO(outstream, avfilter, AVFILTER, flags);
403 #if CONFIG_SWSCALE
393 PRINT_LIB_INFO(outstream, swscale, SWSCALE, flags); 404 PRINT_LIB_INFO(outstream, swscale, SWSCALE, flags);
405 #endif
394 PRINT_LIB_INFO(outstream, postproc, POSTPROC, flags); 406 PRINT_LIB_INFO(outstream, postproc, POSTPROC, flags);
395 } 407 }
396 408
397 void show_banner(void) 409 void show_banner(void)
398 { 410 {
399 fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmp eg developers\n", 411 fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmp eg developers\n",
400 program_name, program_birth_year, this_year); 412 program_name, program_birth_year, this_year);
401 fprintf(stderr, " built on %s %s with %s %s\n", 413 fprintf(stderr, " built on %s %s with %s %s\n",
402 __DATE__, __TIME__, CC_TYPE, CC_VERSION); 414 __DATE__, __TIME__, CC_TYPE, CC_VERSION);
403 fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n"); 415 fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n");
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 ctx->last_pts = reordered_pts; 752 ctx->last_pts = reordered_pts;
741 } 753 }
742 if ((ctx->num_faulty_pts<=ctx->num_faulty_dts || dts == AV_NOPTS_VALUE) 754 if ((ctx->num_faulty_pts<=ctx->num_faulty_dts || dts == AV_NOPTS_VALUE)
743 && reordered_pts != AV_NOPTS_VALUE) 755 && reordered_pts != AV_NOPTS_VALUE)
744 pts = reordered_pts; 756 pts = reordered_pts;
745 else 757 else
746 pts = dts; 758 pts = dts;
747 759
748 return pts; 760 return pts;
749 } 761 }
762
763 #if CONFIG_AVFILTER
764
765 static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque)
766 {
767 FFSinkContext *priv = ctx->priv;
768
769 if (!opaque)
770 return AVERROR(EINVAL);
771 *priv = *(FFSinkContext *)opaque;
772
773 return 0;
774 }
775
776 static void null_end_frame(AVFilterLink *inlink) { }
777
778 static int ffsink_query_formats(AVFilterContext *ctx)
779 {
780 FFSinkContext *priv = ctx->priv;
781 enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
782
783 avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
784 return 0;
785 }
786
787 AVFilter ffsink = {
788 .name = "ffsink",
789 .priv_size = sizeof(FFSinkContext),
790 .init = ffsink_init,
791
792 .query_formats = ffsink_query_formats,
793
794 .inputs = (AVFilterPad[]) {{ .name = "default",
795 .type = AVMEDIA_TYPE_VIDEO,
796 .end_frame = null_end_frame,
797 .min_perms = AV_PERM_READ, },
798 { .name = NULL }},
799 .outputs = (AVFilterPad[]) {{ .name = NULL }},
800 };
801
802 int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
803 AVFilterBufferRef **picref_ptr, AVRational *tb)
804 {
805 int ret;
806 AVFilterBufferRef *picref;
807
808 if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
809 return ret;
810 if (!(picref = ctx->inputs[0]->cur_buf))
811 return AVERROR(ENOENT);
812 *picref_ptr = picref;
813 ctx->inputs[0]->cur_buf = NULL;
814 *tb = ctx->inputs[0]->time_base;
815
816 memcpy(frame->data, picref->data, sizeof(frame->data));
817 memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
818 frame->interlaced_frame = picref->video->interlaced;
819 frame->top_field_first = picref->video->top_field_first;
820
821 return 1;
822 }
823
824 #endif /* CONFIG_AVFILTER */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698