From 1c8bf3bfed5ff5c504c8e3de96188a977f67cce0 Mon Sep 17 00:00:00 2001 From: Victor Lopez Date: Wed, 19 Dec 2012 09:12:24 +0100 Subject: [PATCH 1/3] h264: fix sps parsing for SVC and CAVLC 4:4:4 Intra profiles Fixes bug 396. CC: libav-stable@libav.org --- libavcodec/h264_ps.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 7eb8726ec0..ff6c077ed3 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -333,7 +333,11 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); sps->scaling_matrix_present = 0; - if(sps->profile_idc >= 100){ //high profile + if (sps->profile_idc == 100 || sps->profile_idc == 110 || + sps->profile_idc == 122 || sps->profile_idc == 244 || + sps->profile_idc == 44 || sps->profile_idc == 83 || + sps->profile_idc == 86 || sps->profile_idc == 118 || + sps->profile_idc == 128 || sps->profile_idc == 144) { sps->chroma_format_idc= get_ue_golomb_31(&s->gb); if(sps->chroma_format_idc > 3) { av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc (%u) out of range\n", sps->chroma_format_idc); From bb2bab92e737394a5b91df650fab7f3992c8af59 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 19 Dec 2012 10:31:12 +0100 Subject: [PATCH 2/3] mov: handle h263 and flv1 for codec_tag 'H','2','6','3' The sample in https://bugzilla.libav.org/show_bug.cgi?id=393 and samples/F4V/H263_NM_f.mp4 both have codec_tag H263 for different codecs. H263 is apparently used by Flash Media Server for Sorensen Spark videos. Patch based on commit 5442083b1c541dd166b3adf39131259fc846a62b by Carl Eugen Hoyos. Fixes bug 393. --- libavformat/isom.c | 2 +- libavformat/mov.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.c b/libavformat/isom.c index 1294a1d9a7..ccf4ca1e84 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -211,7 +211,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = { { AV_CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') }, { AV_CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */ - { AV_CODEC_ID_FLV1, MKTAG('H', '2', '6', '3') }, /* Flash Media Server */ + { AV_CODEC_ID_H263, MKTAG('H', '2', '6', '3') }, { AV_CODEC_ID_MSMPEG4V3, MKTAG('3', 'I', 'V', 'D') }, /* 3ivx DivX Doctor */ { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'V', '1', 'x') }, /* AVID 1:1x */ { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'V', 'u', 'p') }, diff --git a/libavformat/mov.c b/libavformat/mov.c index 8503a7ebdd..d5a75c40eb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1171,6 +1171,10 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) /* codec_tag YV12 triggers an UV swap in rawdec.c */ if (!memcmp(st->codec->codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25)) st->codec->codec_tag=MKTAG('I', '4', '2', '0'); + /* Flash Media Server uses tag H263 with Sorenson Spark */ + if (format == MKTAG('H','2','6','3') && + !memcmp(st->codec->codec_name, "Sorenson H263", 13)) + st->codec->codec_id = AV_CODEC_ID_FLV1; st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */ color_table_id = avio_rb16(pb); /* colortable id */ From c661cb6672af5ebcb900ec8766b24761bd2ab011 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 19 Dec 2012 21:53:22 +0100 Subject: [PATCH 3/3] cmdutils: pass number of groups to split_commandline(). This makes the code simpler and avoids mixing designated and non-designated initializers in a potentially unsafe way in avconv. --- avconv_opt.c | 4 ++-- cmdutils.c | 24 +++++++++++------------- cmdutils.h | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/avconv_opt.c b/avconv_opt.c index 6c7017572e..ce32df6b6b 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -1862,7 +1862,6 @@ enum OptGroup { static const OptionGroupDef groups[] = { [GROUP_OUTFILE] = { "output file", NULL }, [GROUP_INFILE] = { "input file", "i" }, - { 0 }, }; static int open_files(OptionGroupList *l, const char *inout, @@ -1907,7 +1906,8 @@ int avconv_parse_options(int argc, char **argv) memset(&octx, 0, sizeof(octx)); /* split the commandline into an internal representation */ - ret = split_commandline(&octx, argc, argv, options, groups); + ret = split_commandline(&octx, argc, argv, options, groups, + FF_ARRAY_ELEMS(groups)); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error splitting the argument list: "); goto fail; diff --git a/cmdutils.c b/cmdutils.c index 578ddf3b6f..1ea05dfe5c 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -443,14 +443,15 @@ int opt_default(void *optctx, const char *opt, const char *arg) * * @return index of the group definition that matched or -1 if none */ -static int match_group_separator(const OptionGroupDef *groups, const char *opt) +static int match_group_separator(const OptionGroupDef *groups, int nb_groups, + const char *opt) { - const OptionGroupDef *p = groups; + int i; - while (p->name) { + for (i = 0; i < nb_groups; i++) { + const OptionGroupDef *p = &groups[i]; if (p->sep && !strcmp(p->sep, opt)) - return p - groups; - p++; + return i; } return -1; @@ -506,17 +507,14 @@ static void add_opt(OptionParseContext *octx, const OptionDef *opt, } static void init_parse_context(OptionParseContext *octx, - const OptionGroupDef *groups) + const OptionGroupDef *groups, int nb_groups) { static const OptionGroupDef global_group = { "global" }; - const OptionGroupDef *g = groups; int i; memset(octx, 0, sizeof(*octx)); - while (g->name) - g++; - octx->nb_groups = g - groups; + octx->nb_groups = nb_groups; octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups); if (!octx->groups) exit(1); @@ -557,14 +555,14 @@ void uninit_parse_context(OptionParseContext *octx) int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, - const OptionGroupDef *groups) + const OptionGroupDef *groups, int nb_groups) { int optindex = 1; /* perform system-dependent conversions for arguments list */ prepare_app_arguments(&argc, &argv); - init_parse_context(octx, groups); + init_parse_context(octx, groups, nb_groups); av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n"); while (optindex < argc) { @@ -592,7 +590,7 @@ do { \ } while (0) /* named group separators, e.g. -i */ - if ((ret = match_group_separator(groups, opt)) >= 0) { + if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) { GET_ARG(arg); finish_group(octx, ret, arg); av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n", diff --git a/cmdutils.h b/cmdutils.h index 1af30d7676..ed9c68e9c0 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -286,7 +286,7 @@ int parse_optgroup(void *optctx, OptionGroup *g); */ int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, - const OptionGroupDef *groups); + const OptionGroupDef *groups, int nb_groups); /** * Free all allocated memory in an OptionParseContext.