Re: [FFmpeg-devel] [PATCH V5 2/2] dnn/native: add log error message
> -Original Message- > From: ffmpeg-devel On Behalf Of Ting Fu > Sent: 2020年8月25日 11:48 > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH V5 2/2] dnn/native: add log error message > > Signed-off-by: Ting Fu > --- > libavfilter/dnn/dnn_backend_native.c | 55 +++ > libavfilter/dnn/dnn_backend_native.h | 5 ++ > .../dnn/dnn_backend_native_layer_avgpool.c| 10 +++- > .../dnn/dnn_backend_native_layer_avgpool.h| 2 +- > .../dnn/dnn_backend_native_layer_conv2d.c | 10 +++- > .../dnn/dnn_backend_native_layer_conv2d.h | 2 +- > .../dnn_backend_native_layer_depth2space.c| 10 +++- > .../dnn_backend_native_layer_depth2space.h| 2 +- > .../dnn/dnn_backend_native_layer_mathbinary.c | 11 > +++- .../dnn/dnn_backend_native_layer_mathbinary.h | 2 > +- .../dnn/dnn_backend_native_layer_mathunary.c | 11 > +++- .../dnn/dnn_backend_native_layer_mathunary.h | 2 +- > .../dnn/dnn_backend_native_layer_maximum.c| 10 +++- > .../dnn/dnn_backend_native_layer_maximum.h| 2 +- > .../dnn/dnn_backend_native_layer_pad.c| 10 +++- > .../dnn/dnn_backend_native_layer_pad.h| 2 +- > libavfilter/dnn/dnn_backend_native_layers.h | 2 +- > tests/dnn/dnn-layer-avgpool-test.c| 4 +- > tests/dnn/dnn-layer-conv2d-test.c | 4 +- > tests/dnn/dnn-layer-depth2space-test.c| 2 +- > tests/dnn/dnn-layer-mathbinary-test.c | 6 +- > tests/dnn/dnn-layer-mathunary-test.c | 2 +- > tests/dnn/dnn-layer-maximum-test.c| 2 +- > tests/dnn/dnn-layer-pad-test.c| 6 +- > 24 files changed, 122 insertions(+), 52 deletions(-) this patch set looks good to me, will push soon, thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v4 3/5] libavcodec/jpeg2000: Modify cleanup
From: Gautam Ramakrishnan This patch makes the ff_jpeg2000_cleanup function take in an extra parameter which indicates whether it is called from the encoder or decoder. --- libavcodec/j2kenc.c | 2 +- libavcodec/jpeg2000.c| 2 +- libavcodec/jpeg2000.h| 2 +- libavcodec/jpeg2000dec.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 87acd2d5c9..711655f1d6 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -1220,7 +1220,7 @@ static void cleanup(Jpeg2000EncoderContext *s) for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ for (compno = 0; compno < s->ncomponents; compno++){ Jpeg2000Component *comp = s->tile[tileno].comp + compno; -ff_jpeg2000_cleanup(comp, codsty); +ff_jpeg2000_cleanup(comp, codsty, 1); } av_freep(&s->tile[tileno].comp); } diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 3d3e7ec313..70c25a0ca2 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -580,7 +580,7 @@ void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) } } -void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) +void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, int isencoder) { int reslevelno, bandno, precno; for (reslevelno = 0; diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index ad58b1ae88..fee9607e86 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -272,7 +272,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty); -void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty); +void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, int isencoder); static inline int needs_termination(int style, int passno) { if (style & JPEG2000_CBLK_BYPASS) { diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 624542c2f8..c5192d007f 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2123,7 +2123,7 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s) Jpeg2000Component *comp = s->tile[tileno].comp + compno; Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno; -ff_jpeg2000_cleanup(comp, codsty); +ff_jpeg2000_cleanup(comp, codsty, 0); } av_freep(&s->tile[tileno].comp); av_freep(&s->tile[tileno].packed_headers); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v4 5/5] doc/encoders.texi: Add documentation for JPEG2000 layers
From: Gautam Ramakrishnan This patch adds documentation for the utility and usage of "layer_rates" option used in the JPEG2000 encoder. --- doc/encoders.texi | 16 1 file changed, 16 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index fd9235a05a..481ad2fb3d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1401,6 +1401,22 @@ Possible values are: @end table Set to @code{lrcp} by default. +@item layer_rates @var{string} +By default, compression is done using the quality metric. This option allows for +compression using compression ratio. The compression ratio for each level could +be specified. The compression ratio of a layer @code{l} species the what ratio of +total file size is contained in the first @code{l} layers. + +Example usage: + +@example +ffmpeg -i input.bmp -c:v jpeg2000 -layer_rates "100,10,1" output.j2k +@end example + +This would compress the image to contain 3 layers, where the data contained in the +first layer would be compressed by 1000 times, compressed by 100 in the first two layers, +and shall contain all data while using all 3 layers. + @end table @section librav1e -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v4 1/5] libavcodec/jpeg2000: Make tag tree functions non static
From: Gautam Ramakrishnan This patch makes the tag_tree_zero() and tag_tree_size() functions non static and callable from other files. --- libavcodec/jpeg2000.c | 12 ++-- libavcodec/jpeg2000.h | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 1aca31ffa4..26e09fbe38 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -39,7 +39,7 @@ /* tag tree routines */ /* allocate the memory for tag tree */ -static int32_t tag_tree_size(int w, int h) +int32_t ff_tag_tree_size(int w, int h) { int64_t res = 0; while (w > 1 || h > 1) { @@ -57,7 +57,7 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h) Jpeg2000TgtNode *res, *t, *t2; int32_t tt_size; -tt_size = tag_tree_size(w, h); +tt_size = ff_tag_tree_size(w, h); t = res = av_mallocz_array(tt_size, sizeof(*t)); if (!res) @@ -82,9 +82,9 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h) return res; } -static void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h) +void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h) { -int i, siz = tag_tree_size(w, h); +int i, siz = ff_tag_tree_size(w, h); for (i = 0; i < siz; i++) { t[i].val = 0; @@ -567,8 +567,8 @@ void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) Jpeg2000Band *band = rlevel->band + bandno; for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++) { Jpeg2000Prec *prec = band->prec + precno; -tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height); -tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height); +ff_tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height); +ff_tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height); for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { Jpeg2000Cblk *cblk = prec->cblk + cblkno; cblk->length = 0; diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index 5b0627c3dc..c3437b02fe 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -290,4 +290,7 @@ static inline int needs_termination(int style, int passno) { return 0; } +int32_t ff_tag_tree_size(int w, int h); +void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h); + #endif /* AVCODEC_JPEG2000_H */ -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v4 2/5] libavcodec/j2kenc: Fix tag tree coding
From: Gautam Ramakrishnan The implementation of tag tree encoding was incorrect. However, this error was not visible as the current j2k encoder encodes only 1 layer. This patch fixes tag tree coding for JPEG2000 such tag tree coding would work for multi layer encoding. --- libavcodec/j2kenc.c | 41 + libavcodec/jpeg2000.c | 1 + libavcodec/jpeg2000.h | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 16863f8e8c..87acd2d5c9 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -242,27 +242,36 @@ static void j2k_flush(Jpeg2000EncoderContext *s) static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, int threshold) { Jpeg2000TgtNode *stack[30]; -int sp = 1, curval = 0; -stack[0] = node; +int sp = -1, curval = 0; -node = node->parent; -while(node){ -if (node->vis){ -curval = node->val; -break; -} -node->vis++; -stack[sp++] = node; +while(node->parent){ +stack[++sp] = node; node = node->parent; } -while(--sp >= 0){ -if (stack[sp]->val >= threshold){ + +while (1) { +if (curval > node->temp_val) +node->temp_val = curval; +else { +curval = node->temp_val; +} + +if (node->val >= threshold) { put_bits(s, 0, threshold - curval); -break; +curval = threshold; +} else { +put_bits(s, 0, node->val - curval); +curval = node->val; +if (!node->vis) { +put_bits(s, 1, 1); +node->vis = 1; +} } -put_bits(s, 0, stack[sp]->val - curval); -put_bits(s, 1, 1); -curval = stack[sp]->val; + +node->temp_val = curval; +if (sp < 0) +break; +node = stack[sp--]; } } diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 26e09fbe38..3d3e7ec313 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -88,6 +88,7 @@ void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h) for (i = 0; i < siz; i++) { t[i].val = 0; +t[i].temp_val = 0; t[i].vis = 0; } } diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index c3437b02fe..ad58b1ae88 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -127,6 +127,7 @@ typedef struct Jpeg2000T1Context { typedef struct Jpeg2000TgtNode { uint8_t val; +uint8_t temp_val; uint8_t vis; struct Jpeg2000TgtNode *parent; } Jpeg2000TgtNode; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v4 4/5] libavcodec/j2kenc: Support for multiple layers
From: Gautam Ramakrishnan This patch allows setting a compression ratio and to set multiple layers. The user has to input a compression ratio for each layer. The per layer compression ration can be set as follows: -layer_rates "r1,r2,...rn" for to create 'n' layers. --- libavcodec/j2kenc.c | 492 +++ libavcodec/jpeg2000.c| 13 +- libavcodec/jpeg2000.h| 10 + tests/ref/vsynth/vsynth1-jpeg2000| 8 +- tests/ref/vsynth/vsynth1-jpeg2000-97 | 6 +- tests/ref/vsynth/vsynth2-jpeg2000| 8 +- tests/ref/vsynth/vsynth2-jpeg2000-97 | 8 +- tests/ref/vsynth/vsynth3-jpeg2000| 8 +- tests/ref/vsynth/vsynth3-jpeg2000-97 | 8 +- tests/ref/vsynth/vsynth_lena-jpeg2000| 8 +- tests/ref/vsynth/vsynth_lena-jpeg2000-97 | 8 +- 11 files changed, 475 insertions(+), 102 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 711655f1d6..0e65adf445 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -32,6 +32,7 @@ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2007, Callum Lerwick + * Copyright (c) 2020, Gautam Ramakrishnan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,6 +101,7 @@ static const int dwt_norms[2][4][10] = { // [dwt_type][band][rlevel] (multiplied typedef struct { Jpeg2000Component *comp; + double *layer_rates; } Jpeg2000Tile; typedef struct { @@ -126,12 +128,16 @@ typedef struct { Jpeg2000QuantStyle qntsty; Jpeg2000Tile *tile; +int layer_rates[100]; +uint8_t compression_rate_enc; ///< Is compression done using compression ratio? int format; int pred; int sop; int eph; int prog; +int nlayers; +char *lr_str; } Jpeg2000EncoderContext; @@ -334,7 +340,7 @@ static int put_cod(Jpeg2000EncoderContext *s) bytestream_put_byte(&s->buf, scod); // Scod // SGcod bytestream_put_byte(&s->buf, s->prog); // progression level -bytestream_put_be16(&s->buf, 1); // num of layers +bytestream_put_be16(&s->buf, s->nlayers); // num of layers if(s->avctx->pix_fmt == AV_PIX_FMT_YUV444P){ bytestream_put_byte(&s->buf, 0); // unspecified }else{ @@ -413,6 +419,31 @@ static uint8_t *put_sot(Jpeg2000EncoderContext *s, int tileno) return psotptr; } +static void compute_rates(Jpeg2000EncoderContext* s) +{ +int i, j; +int layno, compno; +for (i = 0; i < s->numYtiles; i++) { +for (j = 0; j < s->numXtiles; j++) { +Jpeg2000Tile *tile = &s->tile[s->numXtiles * i + j]; +for (compno = 0; compno < s->ncomponents; compno++) { +int tilew = tile->comp[compno].coord[0][1] - tile->comp[compno].coord[0][0]; +int tileh = tile->comp[compno].coord[1][1] - tile->comp[compno].coord[1][0]; +int scale = (compno?1 << s->chroma_shift[0]:1) * (compno?1 << s->chroma_shift[1]:1); +for (layno = 0; layno < s->nlayers; layno++) { +if (s->layer_rates[layno] > 0) { +tile->layer_rates[layno] += (double)(tilew * tileh) * s->ncomponents * s->cbps[compno] / + (double)(s->layer_rates[layno] * 8 * scale); +} else { +tile->layer_rates[layno] = 0.0; +} +} +} +} +} + +} + /** * compute the sizes of tiles, resolution levels, bands, etc. * allocate memory for them @@ -437,6 +468,11 @@ static int init_tiles(Jpeg2000EncoderContext *s) tile->comp = av_mallocz_array(s->ncomponents, sizeof(Jpeg2000Component)); if (!tile->comp) return AVERROR(ENOMEM); + +tile->layer_rates = av_mallocz_array(s->nlayers, sizeof(*tile->layer_rates)); +if (!tile->layer_rates) +return AVERROR(ENOMEM); + for (compno = 0; compno < s->ncomponents; compno++){ Jpeg2000Component *comp = tile->comp + compno; int ret, i, j; @@ -461,6 +497,7 @@ static int init_tiles(Jpeg2000EncoderContext *s) return ret; } } +compute_rates(s); return 0; } @@ -703,6 +740,8 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 } cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len); +cblk->passes[passno].rate -= cblk->passes[passno].flushed_len; + wmsedec += (int64_t)nmsedec << (2*bpno); cblk->passes[passno].disto = wmsedec; @@ -714,8 +753,10 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 cblk->npasses = passno; cbl
[FFmpeg-devel] [PATCH V5 2/2] dnn/native: add log error message
Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native.c | 55 +++ libavfilter/dnn/dnn_backend_native.h | 5 ++ .../dnn/dnn_backend_native_layer_avgpool.c| 10 +++- .../dnn/dnn_backend_native_layer_avgpool.h| 2 +- .../dnn/dnn_backend_native_layer_conv2d.c | 10 +++- .../dnn/dnn_backend_native_layer_conv2d.h | 2 +- .../dnn_backend_native_layer_depth2space.c| 10 +++- .../dnn_backend_native_layer_depth2space.h| 2 +- .../dnn/dnn_backend_native_layer_mathbinary.c | 11 +++- .../dnn/dnn_backend_native_layer_mathbinary.h | 2 +- .../dnn/dnn_backend_native_layer_mathunary.c | 11 +++- .../dnn/dnn_backend_native_layer_mathunary.h | 2 +- .../dnn/dnn_backend_native_layer_maximum.c| 10 +++- .../dnn/dnn_backend_native_layer_maximum.h| 2 +- .../dnn/dnn_backend_native_layer_pad.c| 10 +++- .../dnn/dnn_backend_native_layer_pad.h| 2 +- libavfilter/dnn/dnn_backend_native_layers.h | 2 +- tests/dnn/dnn-layer-avgpool-test.c| 4 +- tests/dnn/dnn-layer-conv2d-test.c | 4 +- tests/dnn/dnn-layer-depth2space-test.c| 2 +- tests/dnn/dnn-layer-mathbinary-test.c | 6 +- tests/dnn/dnn-layer-mathunary-test.c | 2 +- tests/dnn/dnn-layer-maximum-test.c| 2 +- tests/dnn/dnn-layer-pad-test.c| 6 +- 24 files changed, 122 insertions(+), 52 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 436ce938da..a8fe6b94eb 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -28,15 +28,26 @@ #include "dnn_backend_native_layer_conv2d.h" #include "dnn_backend_native_layers.h" +static const AVClass dnn_native_class = { +.class_name = "dnn_native", +.item_name = av_default_item_name, +.option = NULL, +.version= LIBAVUTIL_VERSION_INT, +.category = AV_CLASS_CATEGORY_FILTER, +}; + static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name) { NativeModel *native_model = (NativeModel *)model; +NativeContext *ctx = &native_model->ctx; for (int i = 0; i < native_model->operands_num; ++i) { DnnOperand *oprd = &native_model->operands[i]; if (strcmp(oprd->name, input_name) == 0) { -if (oprd->type != DOT_INPUT) +if (oprd->type != DOT_INPUT) { +av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is not input node\n", input_name); return DNN_ERROR; +} input->dt = oprd->data_type; av_assert0(oprd->dims[0] == 1); input->height = oprd->dims[1]; @@ -47,30 +58,37 @@ static DNNReturnType get_input_native(void *model, DNNData *input, const char *i } // do not find the input operand +av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name); return DNN_ERROR; } static DNNReturnType set_input_native(void *model, DNNData *input, const char *input_name) { NativeModel *native_model = (NativeModel *)model; +NativeContext *ctx = &native_model->ctx; DnnOperand *oprd = NULL; -if (native_model->layers_num <= 0 || native_model->operands_num <= 0) +if (native_model->layers_num <= 0 || native_model->operands_num <= 0) { +av_log(ctx, AV_LOG_ERROR, "No operands or layers in model\n"); return DNN_ERROR; +} /* inputs */ for (int i = 0; i < native_model->operands_num; ++i) { oprd = &native_model->operands[i]; if (strcmp(oprd->name, input_name) == 0) { -if (oprd->type != DOT_INPUT) +if (oprd->type != DOT_INPUT) { +av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is not input node\n", input_name); return DNN_ERROR; +} break; } oprd = NULL; } - -if (!oprd) +if (!oprd) { +av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name); return DNN_ERROR; +} oprd->dims[0] = 1; oprd->dims[1] = input->height; @@ -79,11 +97,15 @@ static DNNReturnType set_input_native(void *model, DNNData *input, const char *i av_freep(&oprd->data); oprd->length = calculate_operand_data_length(oprd); -if (oprd->length <= 0) +if (oprd->length <= 0) { +av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n"); return DNN_ERROR; +} oprd->data = av_malloc(oprd->length); -if (!oprd->data) +if (!oprd->data) { +av_log(ctx, AV_LOG_ERROR, "Failed to malloc memory for input data\n"); return DNN_ERROR; +} input->data = oprd->data; @@ -150,6 +172,8 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename, const char *optio if (!native_model){ goto fail; } + +native_model->ctx.class = &dnn_native_class; model->model = (void
[FFmpeg-devel] [PATCH V5 1/2] dnn/native: unify error return to DNN_ERROR
Unify all error return as DNN_ERROR, in order to cease model executing when return error in ff_dnn_execute_model_native layer_func.pf_exec Signed-off-by: Ting Fu --- V5: rebase to latest code libavfilter/dnn/dnn_backend_native.c | 10 ++ libavfilter/dnn/dnn_backend_native_layer_avgpool.c | 2 +- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 4 ++-- libavfilter/dnn/dnn_backend_native_layer_depth2space.c | 4 ++-- libavfilter/dnn/dnn_backend_native_layer_mathbinary.c | 2 +- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 2 +- libavfilter/dnn/dnn_backend_native_layer_pad.c | 4 ++-- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 65a56704d3..436ce938da 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -246,10 +246,12 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData *output for (layer = 0; layer < native_model->layers_num; ++layer){ DNNLayerType layer_type = native_model->layers[layer].type; -layer_funcs[layer_type].pf_exec(native_model->operands, - native_model->layers[layer].input_operand_indexes, - native_model->layers[layer].output_operand_index, -native_model->layers[layer].params); +if (layer_funcs[layer_type].pf_exec(native_model->operands, + native_model->layers[layer].input_operand_indexes, + native_model->layers[layer].output_operand_index, + native_model->layers[layer].params) == DNN_ERROR) { +return DNN_ERROR; +} } for (uint32_t i = 0; i < nb_output; ++i) { diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c index 8d4d8db98c..bd7bdb4c97 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c +++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c @@ -109,7 +109,7 @@ int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operan output_operand->length = calculate_operand_data_length(output_operand); output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) -return -1; +return DNN_ERROR; output = output_operand->data; for (int y = 0; y < height_end; y += kernel_strides) { diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index a2202e4073..25356901c2 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -114,10 +114,10 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ output_operand->data_type = operands[input_operand_index].data_type; output_operand->length = calculate_operand_data_length(output_operand); if (output_operand->length <= 0) -return -1; +return DNN_ERROR; output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) -return -1; +return DNN_ERROR; output = output_operand->data; av_assert0(channel == conv_params->input_num); diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c index 2c8bddf23d..5a61025f7a 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c +++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c @@ -76,10 +76,10 @@ int dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_ope output_operand->data_type = operands[input_operand_index].data_type; output_operand->length = calculate_operand_data_length(output_operand); if (output_operand->length <= 0) -return -1; +return DNN_ERROR; output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) -return -1; +return DNN_ERROR; output = output_operand->data; for (y = 0; y < height; ++y){ diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c index 7d81694288..6ec1f08e9f 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c @@ -186,6 +186,6 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_ope math_binary_not_commutative(floormod, params, input, output, operands, input_operand_indexes); return 0; default: -return -1; +return DNN_ERROR; } } diff --git a/libavfilter/dnn/dnn_back
Re: [FFmpeg-devel] [RFC PATCH v3 2/5] libavcodec/j2kenc: Fix tag tree coding
On Tue, Aug 25, 2020 at 4:08 AM Michael Niedermayer wrote: > > On Mon, Aug 24, 2020 at 11:10:31PM +0530, gautamr...@gmail.com wrote: > > From: Gautam Ramakrishnan > > > > The implementation of tag tree encoding was incorrect. > > However, this error was not visible as the current j2k > > encoder encodes only 1 layer. > > This patch fixes tag tree coding for JPEG2000 such tag > > tree coding would work for multi layer encoding. > > --- > > libavcodec/j2kenc.c | 41 - > > libavcodec/jpeg2000.c | 1 + > > libavcodec/jpeg2000.h | 1 + > > 3 files changed, 26 insertions(+), 17 deletions(-) > > > > diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c > > index 16863f8e8c..d9777fe07f 100644 > > --- a/libavcodec/j2kenc.c > > +++ b/libavcodec/j2kenc.c > > @@ -242,27 +242,34 @@ static void j2k_flush(Jpeg2000EncoderContext *s) > > static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode > > *node, int threshold) > > { > > Jpeg2000TgtNode *stack[30]; > > -int sp = 1, curval = 0; > > -stack[0] = node; > > +int sp = -1, curval = 0; > > > > -node = node->parent; > > -while(node){ > > -if (node->vis){ > > -curval = node->val; > > -break; > > -} > > -node->vis++; > > -stack[sp++] = node; > > +while(node->parent){ > > +stack[++sp] = node; > > node = node->parent; > > } > > -while(--sp >= 0){ > > -if (stack[sp]->val >= threshold){ > > -put_bits(s, 0, threshold - curval); > > -break; > > + > > +while (1) { > > +if (curval > node->temp_val) > > +node->temp_val = curval; > > +else { > > +curval = node->temp_val; > > } > > -put_bits(s, 0, stack[sp]->val - curval); > > -put_bits(s, 1, 1); > > -curval = stack[sp]->val; > > +while (curval < threshold) { > > +if (curval >= node->val) { > > +if (!node->vis) { > > +node->vis = 1; > > +put_bits(s, 1, 1); > > +} > > +break; > > +} > > +put_bits(s, 0, 1); > > +curval++; > > +} > > why is the put_bits(s, 0, stack[sp]->val - curval); > changed into 1 bit at a time calls ? > a single call should still work with the modified loop > a single call may be faster ... My bad, I oversimplified the implementation as it was hard to debug. Now since I am sure its correct, i'll remove the loop. > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Dictatorship naturally arises out of democracy, and the most aggravated > form of tyranny and slavery out of the most extreme liberty. -- Plato > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- - Gautam | ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware acceleration decoder
> -Original Message- > From: ffmpeg-devel On Behalf Of James > Almer > Sent: Saturday, August 22, 2020 1:22 AM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware > acceleration decoder > > On 8/21/2020 2:05 PM, Derek Buitenhuis wrote: > > On 21/08/2020 16:00, James Almer wrote: > >> If you actually look at the patch, you'll notice that this is > >> basically the template of what eventually will become the native > >> decoder, that for now only includes the high level bitstream parsing > >> and the hwaccel hooks (And thus will only output frames if one is > >> plugged in). So the names are fine. > > > > Isn't there overlap with the parser here (global motion params)? > > cbs_av1 parses global motion params, yes. I'm not sure why this decoder > attempts to do it too, but it acknowledges the fact it's also done by CBS. > Maybe > Fei Wang can explain why the duplication. It should not be duplication. According to spec, gm_params process is: decode_signed_subexp_with_ref() { decode_unsigned_subexp_with_ref() { decode_subexp inverse_recenter } } And csb_av1 just implement decode_subexp part. And all other part need the reference frame's gm_params to calculate current frame's gm_params. So here is the calculation implementation by using result from cbs_av1 with decode_subexp. > > The cbs_av1 gm params parsing code should be fixed, in any case. > > > > > - Derek > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avcodec: add FastAudio decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/fastaudio.c | 200 libavcodec/utils.c | 2 + 6 files changed, 212 insertions(+) create mode 100644 libavcodec/fastaudio.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 191c4e0a7c..6f75f26c84 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -317,6 +317,7 @@ OBJS-$(CONFIG_ESCAPE124_DECODER) += escape124.o OBJS-$(CONFIG_ESCAPE130_DECODER) += escape130.o OBJS-$(CONFIG_EVRC_DECODER)+= evrcdec.o acelp_vectors.o lsp.o OBJS-$(CONFIG_EXR_DECODER) += exr.o exrdsp.o +OBJS-$(CONFIG_FASTAUDIO_DECODER) += fastaudio.o OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1.o OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 084a289c9e..3920eb37ce 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -430,6 +430,7 @@ extern AVCodec ff_dst_decoder; extern AVCodec ff_eac3_encoder; extern AVCodec ff_eac3_decoder; extern AVCodec ff_evrc_decoder; +extern AVCodec ff_fastaudio_decoder; extern AVCodec ff_ffwavesynth_decoder; extern AVCodec ff_flac_encoder; extern AVCodec ff_flac_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index b5bc5c3c71..9a3eaf7d98 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3130,6 +3130,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("CRI HCA"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_FASTAUDIO, +.type = AVMEDIA_TYPE_AUDIO, +.name = "fastaudio", +.long_name = NULL_IF_CONFIG_SMALL("MobiClip FastAudio"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +}, /* subtitle codecs */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index aac1174f28..aac7f63eb6 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -504,6 +504,7 @@ enum AVCodecID { AV_CODEC_ID_MPEGH_3D_AUDIO, AV_CODEC_ID_SIREN, AV_CODEC_ID_HCA, +AV_CODEC_ID_FASTAUDIO, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c new file mode 100644 index 00..354336d17e --- /dev/null +++ b/libavcodec/fastaudio.c @@ -0,0 +1,200 @@ +/* + * MOFLEX Fast Audio decoder + * Copyright (c) 2020 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/intreadwrite.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" +#include "mathops.h" + +typedef struct ChannelItems { +float f[8]; +float last; +} ChannelItems; + +typedef struct FastAudioContext { +float table[8][64]; + +ChannelItems *ch; +} FastAudioContext; + +static av_cold int fastaudio_init(AVCodecContext *avctx) +{ +FastAudioContext *s = avctx->priv_data; + +avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; + +for (int i = 0; i < 8; i++) +s->table[0][i] = (i - 159.5f) / 160.f; +for (int i = 0; i < 11; i++) +s->table[0][i + 8] = (i - 37.5f) / 40.f; +for (int i = 0; i < 27; i++) +s->table[0][i + 8 + 11] = (i - 13.f) / 20.f; +for (int i = 0; i < 11; i++) +s->table[0][i + 8 + 11 + 27] = (i + 27.5f) / 40.f; +for (int i = 0; i < 7; i++) +s->table[0][i + 8 + 11 + 27 + 11] = (i + 152.5f) / 160.f; + +memcpy(s->table[1], s->table[0], sizeof(s->table[0])); + +for (int i = 0; i < 7; i++) +s->table[2][i] = (i - 33.5f) / 40.f; +for (int i = 0; i < 25; i++) +s->table[2][i + 7] = (i - 13.f) / 20.f; + +for (int i = 0; i < 32; i++) +s->table[3][i] = -s->table[2][31 - i]; + +for (int i = 0; i < 16; i++) +s->table[4][i] = i * 0.22f / 3.f - 0.6f; + +for (int i = 0; i < 16; i++) +s->table[5][i] = i * 0.20f / 3.f - 0.3f; + +for (int
Re: [FFmpeg-devel] [PATCH 1/3] avformat: add moflex demuxer
Paul B Mahol: > Signed-off-by: Paul B Mahol > --- > [WIP] Missing video decoder. > --- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/moflex.c | 291 +++ > 3 files changed, 293 insertions(+) > create mode 100644 libavformat/moflex.c > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index cbb33fe37c..1e0ac317e5 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -319,6 +319,7 @@ OBJS-$(CONFIG_MLV_DEMUXER) += mlvdec.o > riffdec.o > OBJS-$(CONFIG_MM_DEMUXER)+= mm.o > OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o > OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o > +OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o > OBJS-$(CONFIG_MOV_DEMUXER) += mov.o mov_chan.o mov_esds.o > replaygain.o > OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o > vpcc.o \ > movenchint.o mov_chan.o rtp.o \ > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 0aa9dd7198..28331facb9 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -249,6 +249,7 @@ extern AVInputFormat ff_mlv_demuxer; > extern AVInputFormat ff_mm_demuxer; > extern AVInputFormat ff_mmf_demuxer; > extern AVOutputFormat ff_mmf_muxer; > +extern AVInputFormat ff_moflex_demuxer; > extern AVInputFormat ff_mov_demuxer; > extern AVOutputFormat ff_mov_muxer; > extern AVOutputFormat ff_mp2_muxer; > diff --git a/libavformat/moflex.c b/libavformat/moflex.c > new file mode 100644 > index 00..b3728b0e49 > --- /dev/null > +++ b/libavformat/moflex.c > @@ -0,0 +1,291 @@ > +/* > + * MOFLEX demuxer > + * Copyright (c) 2020 Paul B Mahol > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#include "avformat.h" > +#include "internal.h" > + > +typedef struct BitReader { > +unsigned last; > +unsigned pos; > +} BitReader; > + > +typedef struct MOFLEXDemuxContext { > +unsigned size; > +int64_t pos; > +int64_t ts; > +int flags; > +int in_block; > + > +BitReader br; > +} MOFLEXDemuxContext; > + > +static int pop(BitReader *br, AVIOContext *pb) > +{ > +if (avio_feof(pb)) > +return AVERROR_EOF; > + > +if ((br->pos & 7) == 0) > +br->last = (unsigned)avio_r8(pb) << 24U; > +else > +br->last <<= 1; > + > +br->pos++; > +return !!(br->last & 0x8000); > +} > + > +static int pop_int(BitReader *br, AVIOContext *pb, int n) > +{ > +int value = 0; > + > +for (int i = 0; i < n; i++) { > +int ret = pop(br, pb); > + > +if (ret < 0) > +return ret; > +value = 2 * value + ret; > +} > + > +return value; > +} > + > +static int pop_length(BitReader *br, AVIOContext *pb) > +{ > +int n = 1; > + > +while (!pop(br, pb)) > +n++; > + > +return n; > +} > + > +static int read_var_byte(AVFormatContext *s, unsigned *out) > +{ > +AVIOContext *pb = s->pb; > +unsigned value = 0, data; > + > +data = avio_r8(pb); > +if (!(data & 0x80)) { > +*out = data; > +return 0; > +} > + > +value = (data & 0x7F) << 7; > +data = avio_r8(pb); > +if (!(data & 0x80)) { > +value |= data; > +*out = value; > +return 0; > +} > + > +value = ((data & 0x7F) | value) << 7; > +data = avio_r8(pb); > +if (!(data & 0x80)) { > +value |= data; > +*out = value; > +return 0; > +} > + > +value = (((data & 0x7F) | value) << 7) | avio_r8(pb); > +*out = value; > + > +return 0; > +} > + > +static int moflex_probe(const AVProbeData *p) > +{ > +if (p->buf[0] != 0x4C && p->buf[1] != 0x32) > +return 0; > + > +return AVPROBE_SCORE_MAX / 3; > +} > + > +static int moflex_read_sync(AVFormatContext *s) > +{ > +MOFLEXDemuxContext *m = s->priv_data; > +AVIOContext *pb = s->pb; > +unsigned v10; > + > +if (avio_rb16(pb) != 0x4C32) { > +avio_seek(pb, -2, SEEK_CUR); > +return 1; > +} > + > +v10 = avio_rb16(pb); > +m->ts = avio_rb64(pb); > +m->size = avio_rb16(pb) + 1; > + > +
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3
On Mon, Aug 24, 2020 at 11:02:22PM +0200, Marton Balint wrote: > > > On Mon, 24 Aug 2020, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > Explain the reason in the commit message, e.g: > > Some DVB and ATSC captures are using the official MPEG2 registration > descriptor in addition to using the correct stream type and the > AC-3_audio_stream_descriptor/AC3_descriptor. So let's add it even if it is > not strictly needed for DVB/ATSC. It looks good tome, will update with these commit message. > > > > > Signed-off-by: Limin Wang > > --- > > libavformat/mpegtsenc.c | 4 > > 1 file changed, 4 insertions(+) > > > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > > index 61fdd09..5a9e6fd 100644 > > --- a/libavformat/mpegtsenc.c > > +++ b/libavformat/mpegtsenc.c > > @@ -487,6 +487,10 @@ static int mpegts_write_pmt(AVFormatContext *s, > > MpegTSService *service) > > /* write optional descriptors here */ > > switch (st->codecpar->codec_type) { > > case AVMEDIA_TYPE_AUDIO: > > +if (codec_id == AV_CODEC_ID_AC3) > > +put_registration_descriptor(&q, MKTAG('A', 'C', '-', '3')); > > +else if (codec_id == AV_CODEC_ID_EAC3) > > "else" is not really needed, I'd rather avoid it for consistency with > similar code below. will remove else. > > > +put_registration_descriptor(&q, MKTAG('E', 'A', 'C', '3')); > > Otherwise LGTM. > > Thanks, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avformat: add moflex demuxer
Signed-off-by: Paul B Mahol --- [WIP] Missing video decoder. --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/moflex.c | 291 +++ 3 files changed, 293 insertions(+) create mode 100644 libavformat/moflex.c diff --git a/libavformat/Makefile b/libavformat/Makefile index cbb33fe37c..1e0ac317e5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -319,6 +319,7 @@ OBJS-$(CONFIG_MLV_DEMUXER) += mlvdec.o riffdec.o OBJS-$(CONFIG_MM_DEMUXER)+= mm.o OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o +OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o OBJS-$(CONFIG_MOV_DEMUXER) += mov.o mov_chan.o mov_esds.o replaygain.o OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o \ movenchint.o mov_chan.o rtp.o \ diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 0aa9dd7198..28331facb9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -249,6 +249,7 @@ extern AVInputFormat ff_mlv_demuxer; extern AVInputFormat ff_mm_demuxer; extern AVInputFormat ff_mmf_demuxer; extern AVOutputFormat ff_mmf_muxer; +extern AVInputFormat ff_moflex_demuxer; extern AVInputFormat ff_mov_demuxer; extern AVOutputFormat ff_mov_muxer; extern AVOutputFormat ff_mp2_muxer; diff --git a/libavformat/moflex.c b/libavformat/moflex.c new file mode 100644 index 00..b3728b0e49 --- /dev/null +++ b/libavformat/moflex.c @@ -0,0 +1,291 @@ +/* + * MOFLEX demuxer + * Copyright (c) 2020 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "internal.h" + +typedef struct BitReader { +unsigned last; +unsigned pos; +} BitReader; + +typedef struct MOFLEXDemuxContext { +unsigned size; +int64_t pos; +int64_t ts; +int flags; +int in_block; + +BitReader br; +} MOFLEXDemuxContext; + +static int pop(BitReader *br, AVIOContext *pb) +{ +if (avio_feof(pb)) +return AVERROR_EOF; + +if ((br->pos & 7) == 0) +br->last = (unsigned)avio_r8(pb) << 24U; +else +br->last <<= 1; + +br->pos++; +return !!(br->last & 0x8000); +} + +static int pop_int(BitReader *br, AVIOContext *pb, int n) +{ +int value = 0; + +for (int i = 0; i < n; i++) { +int ret = pop(br, pb); + +if (ret < 0) +return ret; +value = 2 * value + ret; +} + +return value; +} + +static int pop_length(BitReader *br, AVIOContext *pb) +{ +int n = 1; + +while (!pop(br, pb)) +n++; + +return n; +} + +static int read_var_byte(AVFormatContext *s, unsigned *out) +{ +AVIOContext *pb = s->pb; +unsigned value = 0, data; + +data = avio_r8(pb); +if (!(data & 0x80)) { +*out = data; +return 0; +} + +value = (data & 0x7F) << 7; +data = avio_r8(pb); +if (!(data & 0x80)) { +value |= data; +*out = value; +return 0; +} + +value = ((data & 0x7F) | value) << 7; +data = avio_r8(pb); +if (!(data & 0x80)) { +value |= data; +*out = value; +return 0; +} + +value = (((data & 0x7F) | value) << 7) | avio_r8(pb); +*out = value; + +return 0; +} + +static int moflex_probe(const AVProbeData *p) +{ +if (p->buf[0] != 0x4C && p->buf[1] != 0x32) +return 0; + +return AVPROBE_SCORE_MAX / 3; +} + +static int moflex_read_sync(AVFormatContext *s) +{ +MOFLEXDemuxContext *m = s->priv_data; +AVIOContext *pb = s->pb; +unsigned v10; + +if (avio_rb16(pb) != 0x4C32) { +avio_seek(pb, -2, SEEK_CUR); +return 1; +} + +v10 = avio_rb16(pb); +m->ts = avio_rb64(pb); +m->size = avio_rb16(pb) + 1; + +while (!avio_feof(pb)) { +unsigned type, ssize, codec_id = 0; +unsigned codec_type, width = 0, height = 0, sample_rate = 0, channels = 0; +int stream_index = -1; +int format; +AVRational fps; + +read_var_byte(s, &type); +read_var_byte(s, &ssize); + +switch (type) { +case 0: +if (ssize >
[FFmpeg-devel] [PATCH 2/3] avcodec: add ADPCM IMA MOFLEX decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/adpcm.c | 26 ++ libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 +++ libavcodec/codec_id.h | 1 + libavcodec/utils.c | 2 ++ 6 files changed, 38 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ca2e8a2530..191c4e0a7c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -866,6 +866,7 @@ OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_IMA_MOFLEX_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_MTF_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_OKI_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o adpcm_data.o diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 1366932352..71e37efde7 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -210,6 +210,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) case AV_CODEC_ID_ADPCM_PSX: case AV_CODEC_ID_ADPCM_MTAF: case AV_CODEC_ID_ADPCM_ARGO: +case AV_CODEC_ID_ADPCM_IMA_MOFLEX: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break; case AV_CODEC_ID_ADPCM_IMA_WS: @@ -774,6 +775,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, case AV_CODEC_ID_ADPCM_4XM: case AV_CODEC_ID_ADPCM_AGM: case AV_CODEC_ID_ADPCM_IMA_DAT4: +case AV_CODEC_ID_ADPCM_IMA_MOFLEX: case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break; case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break; case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break; @@ -1298,6 +1300,29 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3); } break; +case AV_CODEC_ID_ADPCM_IMA_MOFLEX: +for (channel = 0; channel < avctx->channels; channel++) { +cs = &c->status[channel]; +cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); +cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); +if (cs->step_index > 88u){ +av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n", + channel, cs->step_index); +return AVERROR_INVALIDDATA; +} +} + +for (int subframe = 0; subframe < nb_samples / 256; subframe++) { +for (channel = 0; channel < avctx->channels; channel++) { +samples = samples_p[channel] + 256 * subframe; +for (n = 0; n < 256; n += 2) { +int v = bytestream2_get_byteu(&gb); +*samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); +*samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); +} +} +} +break; case AV_CODEC_ID_ADPCM_IMA_DAT4: for (channel = 0; channel < avctx->channels; channel++) { cs = &c->status[channel]; @@ -2107,6 +2132,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, sample_fmts_s16, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, sample_fmts_s16, adpcm_ima_iss, "ADPCM IMA Funcom ISS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_MOFLEX, sample_fmts_s16p, adpcm_ima_moflex, "ADPCM IMA MobiClip MOFLEX"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_MTF, sample_fmts_s16, adpcm_ima_mtf, "ADPCM IMA Capcom's MT Framework"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_OKI, sample_fmts_s16, adpcm_ima_oki, "ADPCM IMA Dialogic OKI"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, "ADPCM IMA QuickTime"); diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 729d2fd9ad..084a289c9e 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -619,6 +619,7 @@ extern AVCodec ff_adpcm_ima_dk4_decoder; extern AVCodec ff_adpcm_ima_ea_eacs_decoder; extern AVCodec ff_adpcm_ima_ea_sead_decoder; extern AVCodec ff_adpcm_ima_iss_decoder; +extern AVCodec ff_adpcm_ima_moflex_decoder; extern AVCodec ff_adpcm_ima_mtf_decoder; extern AVCodec ff_adpcm_ima_oki_decoder; extern AVCodec ff_adpcm_ima_qt_encoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 0ae6aee63b..b5bc5c3c71 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2376,6 +2376,13 @@ static const AVCodecD
Re: [FFmpeg-devel] [PATCH]lavfi/hflip: Support Bayer pixel formats
Am So., 26. Juli 2020 um 21:59 Uhr schrieb Carl Eugen Hoyos : > > Am So., 26. Juli 2020 um 21:28 Uhr schrieb Paul B Mahol : > > > > On 7/26/20, Carl Eugen Hoyos wrote: > > > Hi! > > > > > > Attached patch fixes a part of ticket #8819. > > > > > > Please comment, Carl Eugen > > > > > > > Looks good, but variable name is unfortunate. > > New patch attached. Patch applied. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/mxfdec: Limit score for strangely cut files
Am Di., 25. Aug. 2020 um 00:48 Uhr schrieb Tomas Härdin : > > mån 2020-08-24 klockan 21:42 +0200 skrev Carl Eugen Hoyos: > > Hi! > > > > Attached patch fixes ticket #8846, the sample there is both a mov and > > an mxf file. > > It is not entirely clear to me if the sample was only made to annoy us > > but the content looks real. > > > > An alternative may be to check the extension if the score is equal but > > I don't really like that either. > > The file is a polyglot, yes. The run-in feature in MXF exists to be > able to add extra metadata and other MXF features while maintaining > backward compatibility. And to be annoying. The file does not play here with -f mxf... > > Subject: [PATCH] lavf/mxfdec: Limit score for strangely cut files. > > I'd reword this to "lavf/mxfdec: Limit score for files with run-in" > > > @@ -3615,7 +3615,7 @@ static int mxf_probe(const AVProbeData *p) { > > AV_RN32(bufp+ 4) == AV_RN32(mxf_header_partition_pack_key+ > > 4) && > > AV_RN32(bufp+ 8) == AV_RN32(mxf_header_partition_pack_key+ > > 8) && > > AV_RN16(bufp+12) == > > AV_RN16(mxf_header_partition_pack_key+12)) > > -return AVPROBE_SCORE_MAX; > > +return bufp - p->buf ? AVPROBE_SCORE_MAX - 1 : > > AVPROBE_SCORE_MAX; > > bufp != p->buf would be more readable. Else this does the same thing as > a patch I was just working on, so the logic is OK. Patch applied. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/mxfdec: Limit score for strangely cut files
mån 2020-08-24 klockan 21:42 +0200 skrev Carl Eugen Hoyos: > Hi! > > Attached patch fixes ticket #8846, the sample there is both a mov and > an mxf file. > It is not entirely clear to me if the sample was only made to annoy us > but the content looks real. > > An alternative may be to check the extension if the score is equal but > I don't really like that either. The file is a polyglot, yes. The run-in feature in MXF exists to be able to add extra metadata and other MXF features while maintaining backward compatibility. And to be annoying. > Subject: [PATCH] lavf/mxfdec: Limit score for strangely cut files. I'd reword this to "lavf/mxfdec: Limit score for files with run-in" > @@ -3615,7 +3615,7 @@ static int mxf_probe(const AVProbeData *p) { > AV_RN32(bufp+ 4) == AV_RN32(mxf_header_partition_pack_key+ > 4) && > AV_RN32(bufp+ 8) == AV_RN32(mxf_header_partition_pack_key+ > 8) && > AV_RN16(bufp+12) == > AV_RN16(mxf_header_partition_pack_key+12)) > -return AVPROBE_SCORE_MAX; > +return bufp - p->buf ? AVPROBE_SCORE_MAX - 1 : > AVPROBE_SCORE_MAX; bufp != p->buf would be more readable. Else this does the same thing as a patch I was just working on, so the logic is OK. /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC PATCH v3 2/5] libavcodec/j2kenc: Fix tag tree coding
On Mon, Aug 24, 2020 at 11:10:31PM +0530, gautamr...@gmail.com wrote: > From: Gautam Ramakrishnan > > The implementation of tag tree encoding was incorrect. > However, this error was not visible as the current j2k > encoder encodes only 1 layer. > This patch fixes tag tree coding for JPEG2000 such tag > tree coding would work for multi layer encoding. > --- > libavcodec/j2kenc.c | 41 - > libavcodec/jpeg2000.c | 1 + > libavcodec/jpeg2000.h | 1 + > 3 files changed, 26 insertions(+), 17 deletions(-) > > diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c > index 16863f8e8c..d9777fe07f 100644 > --- a/libavcodec/j2kenc.c > +++ b/libavcodec/j2kenc.c > @@ -242,27 +242,34 @@ static void j2k_flush(Jpeg2000EncoderContext *s) > static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, > int threshold) > { > Jpeg2000TgtNode *stack[30]; > -int sp = 1, curval = 0; > -stack[0] = node; > +int sp = -1, curval = 0; > > -node = node->parent; > -while(node){ > -if (node->vis){ > -curval = node->val; > -break; > -} > -node->vis++; > -stack[sp++] = node; > +while(node->parent){ > +stack[++sp] = node; > node = node->parent; > } > -while(--sp >= 0){ > -if (stack[sp]->val >= threshold){ > -put_bits(s, 0, threshold - curval); > -break; > + > +while (1) { > +if (curval > node->temp_val) > +node->temp_val = curval; > +else { > +curval = node->temp_val; > } > -put_bits(s, 0, stack[sp]->val - curval); > -put_bits(s, 1, 1); > -curval = stack[sp]->val; > +while (curval < threshold) { > +if (curval >= node->val) { > +if (!node->vis) { > +node->vis = 1; > +put_bits(s, 1, 1); > +} > +break; > +} > +put_bits(s, 0, 1); > +curval++; > +} why is the put_bits(s, 0, stack[sp]->val - curval); changed into 1 bit at a time calls ? a single call should still work with the modified loop a single call may be faster ... thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3 v3] avcodec/aacdec_template: add more checks to make sure only 22.2 gets to 22.2
On Mon, Aug 24, 2020 at 11:04 PM Paul B Mahol wrote: > > On 8/22/20, Carl Eugen Hoyos wrote: > > Am Sa., 22. Aug. 2020 um 23:15 Uhr schrieb Jan Ekström : > >> > >> On Sat, Aug 22, 2020 at 11:42 PM Carl Eugen Hoyos > >> wrote: > >> > > >> > Am Sa., 22. Aug. 2020 um 22:40 Uhr schrieb Jan Ekström > >> > : > >> > > > >> > > Validates the set channel layout as well as verifies that the received > >> > > layout to the function matches the reference layout, so that it > >> > > matches > >> > > the implemented re-ordering logic. > >> > > > >> > > Fixes #8845 > >> > > >> > Did you also see tickets #8859 and #8860? > >> > > >> > >> No, but I just tested them and each and every version of the patch set > >> on the mailing list starting from the 18th did indeed make them not > >> happen, incl. the current one. > > > > Thank you for confirming this! > > Patches should be fine. > > There is only one way to find if that patch breaks good/normal files. > Thanks for taking a look. Applied patches 1 and 2 as de1d6aa0a3d4358e9975e0d6fe5c655fd38694fe and d6f293353c94c7ce200f6e0975ae3de49787f91f. With 1/2 while doing final verifications I noticed I had accidentally left one case of setting layout to UINT64_MAX, so there is a small diff to the posted version: diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 10ceeca261..5906ed20b3 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -410,15 +410,14 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags) while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { e2c_vec[i] = (struct elem_to_channel) { .av_position = UINT64_MAX, .syn_ele = TYPE_LFE, .elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_LFE }; -layout |= e2c_vec[i].av_position; i++; } // The previous checks would end up at 8 at this point for 22.2 if (layout == PREFIX_FOR_22POINT2 && tags == 16 && i == 8) { const uint8_t (*reference_layout_map)[3] = aac_channel_layout_map[12]; for (int j = 0; j < tags; j++) { UINT64_MAX is not supposed to be applied to the layout bit mask, so this was just a mistake by me while making the original patch. As for real life cases, the only files I've seen so far beyond 10.2 have been 22.2 broadcast samples, and those still successfully get parsed as they just have channel_config = 13. Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/mpegts: Support mulaw audio in Lorex LNC recordings
Am Mo., 24. Aug. 2020 um 21:56 Uhr schrieb Carl Eugen Hoyos : > Attached patch allows audio decoding in Lorex LNC recordings, > tested with hi- and low-res files. Sorry. this cannot work, not sure how to detect such recordings. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/mpegtsenc: reindent the code
On Mon, 24 Aug 2020, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- libavformat/mpegtsenc.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 5a9e6fd..1559ce6 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1744,24 +1744,24 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) av_log(s, AV_LOG_ERROR, "AAC bitstream not in ADTS format " "and extradata missing\n"); } else { -av_init_packet(&pkt2); -pkt2.data = pkt->data; -pkt2.size = pkt->size; -av_assert0(pkt->dts != AV_NOPTS_VALUE); -pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base); - -ret = avio_open_dyn_buf(&ts_st->amux->pb); -if (ret < 0) -return ret; - -ret = av_write_frame(ts_st->amux, &pkt2); -if (ret < 0) { -ffio_free_dyn_buf(&ts_st->amux->pb); -return ret; -} -size= avio_close_dyn_buf(ts_st->amux->pb, &data); -ts_st->amux->pb = NULL; -buf = data; +av_init_packet(&pkt2); +pkt2.data = pkt->data; +pkt2.size = pkt->size; +av_assert0(pkt->dts != AV_NOPTS_VALUE); +pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base); + +ret = avio_open_dyn_buf(&ts_st->amux->pb); +if (ret < 0) +return ret; + +ret = av_write_frame(ts_st->amux, &pkt2); +if (ret < 0) { +ffio_free_dyn_buf(&ts_st->amux->pb); +return ret; +} +size= avio_close_dyn_buf(ts_st->amux->pb, &data); +ts_st->amux->pb = NULL; +buf = data; } } } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { LGTM, thanks. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3
On Mon, 24 Aug 2020, lance.lmw...@gmail.com wrote: From: Limin Wang Explain the reason in the commit message, e.g: Some DVB and ATSC captures are using the official MPEG2 registration descriptor in addition to using the correct stream type and the AC-3_audio_stream_descriptor/AC3_descriptor. So let's add it even if it is not strictly needed for DVB/ATSC. Signed-off-by: Limin Wang --- libavformat/mpegtsenc.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 61fdd09..5a9e6fd 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -487,6 +487,10 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) /* write optional descriptors here */ switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_AUDIO: +if (codec_id == AV_CODEC_ID_AC3) +put_registration_descriptor(&q, MKTAG('A', 'C', '-', '3')); +else if (codec_id == AV_CODEC_ID_EAC3) "else" is not really needed, I'd rather avoid it for consistency with similar code below. +put_registration_descriptor(&q, MKTAG('E', 'A', 'C', '3')); Otherwise LGTM. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/mpegts: Support mulaw audio in Lorex LNC recordings
On Mon, 24 Aug 2020, Carl Eugen Hoyos wrote: Hi! Attached patch allows audio decoding in Lorex LNC recordings, tested with hi- and low-res files. Please share some samples. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3 v3] avcodec/aacdec_template: add more checks to make sure only 22.2 gets to 22.2
On 8/22/20, Carl Eugen Hoyos wrote: > Am Sa., 22. Aug. 2020 um 23:15 Uhr schrieb Jan Ekström : >> >> On Sat, Aug 22, 2020 at 11:42 PM Carl Eugen Hoyos >> wrote: >> > >> > Am Sa., 22. Aug. 2020 um 22:40 Uhr schrieb Jan Ekström >> > : >> > > >> > > Validates the set channel layout as well as verifies that the received >> > > layout to the function matches the reference layout, so that it >> > > matches >> > > the implemented re-ordering logic. >> > > >> > > Fixes #8845 >> > >> > Did you also see tickets #8859 and #8860? >> > >> >> No, but I just tested them and each and every version of the patch set >> on the mailing list starting from the 18th did indeed make them not >> happen, incl. the current one. > > Thank you for confirming this! Patches should be fine. There is only one way to find if that patch breaks good/normal files. > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH]lavf/mpegts: Support mulaw audio in Lorex LNC recordings
Hi! Attached patch allows audio decoding in Lorex LNC recordings, tested with hi- and low-res files. Please comment, Carl Eugen From 4ade92cd6612a21226ea42113bb66deacfd2b8e1 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 24 Aug 2020 21:52:52 +0200 Subject: [PATCH] lavf/mpegts: Support mulaw audio in Lorex LNC files. --- libavformat/mpegts.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 50d4d5e9bc..b159d40368 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -153,6 +153,8 @@ struct MpegTSContext { int resync_size; int merge_pmt_versions; +/* Lorex LNC crf file */ +int lorex_crf; /**/ /* private mpegts data */ @@ -860,6 +862,10 @@ static const StreamType METADATA_types[] = { { 0 }, }; +static const StreamType crf_types[] = { +{ 0x06, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_MULAW }, +}; + /* descriptor present */ static const StreamType DESC_types[] = { { 0x6a, AVMEDIA_TYPE_AUDIO,AV_CODEC_ID_AC3 }, /* AC-3 descriptor */ @@ -947,6 +953,12 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, } if (st->codecpar->codec_id == AV_CODEC_ID_NONE) mpegts_find_stream_type(st, pes->stream_type, MISC_types); +if (pes->ts->lorex_crf && st->codecpar->codec_id == AV_CODEC_ID_NONE) +mpegts_find_stream_type(st, pes->stream_type, crf_types); +if (st->codecpar->codec_id == AV_CODEC_ID_PCM_MULAW) { +st->codecpar->channels = 1; +st->codecpar->sample_rate = 8000; +} if (st->codecpar->codec_id == AV_CODEC_ID_NONE) { st->codecpar->codec_id = old_codec_id; st->codecpar->codec_type = old_codec_type; @@ -3054,8 +3066,13 @@ static int mpegts_read_header(AVFormatContext *s) s->internal->prefer_codec_framerate = 1; -if (ffio_ensure_seekback(pb, probesize) < 0) +if (ffio_ensure_seekback(pb, probesize) < 0) { av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); +} else { +if ((avio_rb64(pb) & 0xFF00) == 0x47401142b025) +ts->lorex_crf = 1; +avio_seek(pb, -8, SEEK_CUR); +} pos = avio_tell(pb); ts->raw_packet_size = get_packet_size(s); -- 2.24.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH]lavf/mxfdec: Limit score for strangely cut files
Hi! Attached patch fixes ticket #8846, the sample there is both a mov and an mxf file. It is not entirely clear to me if the sample was only made to annoy us but the content looks real. An alternative may be to check the extension if the score is equal but I don't really like that either. Other solutions welcome, Carl Eugen From 4e6ff4465f9d2928b181b5cfc652d45b703a82f4 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 24 Aug 2020 21:37:00 +0200 Subject: [PATCH] lavf/mxfdec: Limit score for strangely cut files. Only return AVPROBE_SCORE_MAX if the header partition pack key is at the start of the file. Fixes ticket #8846. --- libavformat/mxfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..14b430a8d4 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3615,7 +3615,7 @@ static int mxf_probe(const AVProbeData *p) { AV_RN32(bufp+ 4) == AV_RN32(mxf_header_partition_pack_key+ 4) && AV_RN32(bufp+ 8) == AV_RN32(mxf_header_partition_pack_key+ 8) && AV_RN16(bufp+12) == AV_RN16(mxf_header_partition_pack_key+12)) -return AVPROBE_SCORE_MAX; +return bufp - p->buf ? AVPROBE_SCORE_MAX - 1 : AVPROBE_SCORE_MAX; bufp ++; } else bufp += 10; -- 2.24.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Built-in documentation API
On 2020-08-23 08:21, Nicolas George wrote: Since the idea of documentation built in the libraries seems popular, I have tried to outline an API to access it.… See the attached file […`documentation.c` omitted…]. Some comments about the API outline itself, from `documentation.c`: struct AVDocNode { /** * Names of the component. * * It is a concatenation of 0-terminated strings, terminated by an empty * string (i.e. a double 0). * For example "frame_rate, rate, r" would be "frame_rate\0rate\0r\0\0". * The first name is the main name of the component, the other are * aliases. * If this field is used as a plain C string, it contains only the main * name. */ const char *names; The type "const char *" implies a single null-terminated string. Is it usual in the codebase to use it to refer to a concatenation of null-terminated strings? It seems that having a type which means "concatenation of null-terminated strings" would be clearer. How is this concatenation itself terminated? If I am walking the null-terminated strings with a char * pointer, how do I know I have reached the end? I don't see this defined. You could say that a null-terminated string of length zero terminates it. This then requires that the other strings in `names` have length >= 1. /** * Unique identifier of the compnent. * * It is composed of alphanumeric characters plus underscore and slash * and written hierarchically. * * For example, the width option of the scale filter would be * "lavfi/vf_scale/opt_width". * * This identifier can be used for links in the text. * * It matches the symbol that makes the documentation available, in the * avdoc_ namespace with double underscore standing for slashes: * extern const AVDocNode avdoc_lavfi__vf_scale__opt_width; */ const char *id; This attribute is defined as a "unique identifier", but the example value alludes to sort of path through a hierarchy. If values have a path-like structure, sooner or later clients will start to parse that structure, then depend on it. If you don't want them to do that, then perhaps state that this value is opaque, and give an example which is a universally unique but arbitrary value. If you do want them to do that, then be explicit about what the internal structure is. /** * Links towards other nodes. * * All nodes linked in the text must have an entry here, but implicit * links are possible too, for example the type of an option. * * The types are ordered by type. */ const AVDocLink *links; The type AVDocLink * implies a pointer to a single AVDocLink, but the plural word "links" implies that this is an array of AVDocLink structures. If you intend this pointer to point to an array, I suggest you make that clear. Also, how will a client know how long the array is? Will there be a sentinal AVDocLink value which means "end of array"? const char *id; const char *title; const char *text; The termination of these strings is not specified. I suspect you mean them to be null-terminated C strings, but it is perhaps better to say so explicitly. Also, a narrative of how this API is used would be helpful. Who calls it? What is the structure of AVDocNodes expected to be returned? What is the client expected to do with this? Also, out of scope of an API doc, but since I'm here: I'd be interested to see how this structure is serialised in the executable file. How are the AVDocNodes delimited from one another? How are AVDocLink values serialised? Will there be a version field in the serialised structure? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Set AVSTREAM_PARSE_HEADERS flag for AV1 MP4 streams
On 8/24/2020 3:18 AM, Vikas Agrawal (Engrg-SW) wrote: > > Please review: > It help initialize chroma format and other info properly > Chroma format wasn't correct if I use below code: > avformat_find_stream_info(fmtc, NULL); > iVideoStream = av_find_best_stream(fmtc, AVMEDIA_TYPE_VIDEO, -1, -1, > NULL, 0); > eChromaFormat = > (AVPixelFormat)fmtc->streams[iVideoStream]->codecpar->format; > --- > libavformat/mov.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 1532e74d67..4c8598c992 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -2423,6 +2423,9 @@ static int mov_finalize_stsd_codec(MOVContext *c, > AVIOContext *pb, > case AV_CODEC_ID_VP9: > st->need_parsing = AVSTREAM_PARSE_FULL; > break; > +case AV_CODEC_ID_AV1: > +st->need_parsing = AVSTREAM_PARSE_HEADERS; > +break; > default: > break; > } Applied, thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user plugin since libmfx 1.28
> -Original Message- > From: ffmpeg-devel On Behalf Of > Xiang, Haihao > Sent: Monday, August 24, 2020 8:15 AM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user plugin > since libmfx 1.28 > > On Fri, 2020-08-21 at 20:11 +, Soft Works wrote: > > > -Original Message- > > > From: ffmpeg-devel On Behalf Of > > > Soft Works > > > Sent: Friday, August 21, 2020 9:45 AM > > > To: FFmpeg development discussions and patches > > de...@ffmpeg.org> > > > Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user > > > plugin since libmfx 1.28 > > > > > > > > > > > > > -Original Message- > > > > From: ffmpeg-devel On Behalf > Of > > > > Xiang, Haihao > > > > Sent: Friday, August 21, 2020 9:29 AM > > > > To: ffmpeg-devel@ffmpeg.org > > > > Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user > > > > plugin since libmfx 1.28 > > > > > > > > On Fri, 2020-08-21 at 05:48 +, Soft Works wrote: > > > > > > -Original Message- > > > > > > From: ffmpeg-devel On > Behalf > > > > > > Of > > > > > > Haihao Xiang > > > > > > Sent: Friday, August 21, 2020 7:23 AM > > > > > > To: ffmpeg-devel@ffmpeg.org > > > > > > Cc: Haihao Xiang > > > > > > Subject: [FFmpeg-devel] [PATCH v2 1/2] qsv: needn't load user > > > > > > plugin since libmfx 1.28 > > > > > > > > > > > > MFXVideoUSER_Load call is redundant since libmfx 1.28 > > > > > > --- > > > > > > Fixed merge conflict when applying this patch by 'git am' > > > > > > > > > > > > libavcodec/qsv.c | 9 - > > > > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > > > > > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index > > > > > > 17720070f1..56a30ad642 100644 > > > > > > --- a/libavcodec/qsv.c > > > > > > +++ b/libavcodec/qsv.c > > > > > > @@ -19,7 +19,6 @@ > > > > > > */ > > > > > > > > > > > > #include > > > > > > -#include > > > > > > #include > > > > > > > > > > > > #include > > > > > > @@ -36,6 +35,10 @@ > > > > > > #include "avcodec.h" > > > > > > #include "qsv_internal.h" > > > > > > > > > > > > +#if !QSV_VERSION_ATLEAST(1, 28) #include > > > > > > +#endif > > > > > > + > > > > > > #if QSV_VERSION_ATLEAST(1, 12) #include "mfx/mfxvp8.h" > > > > > > #endif > > > > > > @@ -295,6 +298,9 @@ enum AVPictureType > ff_qsv_map_pictype(int > > > > > > mfx_pic_type) static int qsv_load_plugins(mfxSession session, > > > > > > const char *load_plugins, > > > > > > void *logctx) { > > > > > > +#if QSV_VERSION_ATLEAST(1, 28) > > > > > > +return 0; > > > > > > +#else > > > > > > if (!load_plugins || !*load_plugins) > > > > > > return 0; > > > > > > > > > > > > @@ -340,6 +346,7 @@ load_plugin_fail: > > > > > > } > > > > > > > > > > > > return 0; > > > > > > +#endif > > > > > > > > > > > > } > > > > > > > > > > > > > > > Hi, > > > > > > > > > > Are you sure this check is right? You are checking the libmfx > > > > > version against which ffmpeg is compiled. > > > > > > > > > > What happens, when a graphics driver supports only API level 1.21? > > > > > > > > > > > > > I understand your concern, however lots of features in FFmpeg are > > > > disabled/enabled against api version at compile-time. > > > > > > That is in no way an argument to break compatibility with downlevel > > > drivers without any need. Things are working fine without that patch > > > for all API versions. > > > > > > If you really want to avoid the plugin-load, then you should check > > > the driver's API level at runtime. > > > > Haihao, > > > > let me add a few more points to this subject: > > > > - Backwards-Compatibility is a key feature of the Intel Media SDK > > Your colleagues which are doing the MSDK development are continuously > > taking care to make that possible > > > > - When you look at the latest release notes (MSDK 2020 R1, API 1.32), > > you can see that 3rd, 4th and 5th gen CPUs are still supported > > The latest 3rd gen drivers are API level 1.11 > > The latest 4th and 5th gen drivers are API level 1.20 > > Also later CPUs do not always have the latest drivers (> 1.28) > > installed > > > > - Even with libmfx 1.32, it is still possible to use those CPUs or older > > driver versions, and that applies to ffmpeg as well, when it's compiled > > against libmfx 1.32 > > > > - Your change would only be legitimate if there would have been a change > > In the dispatcher code since API 1.28 that would automatically handle the > > Plugin loading for drivers < 1.28. > > But I have just gone through the recent changes to the dispatcher code > > And there doesn't exist such functionality. > > > > - For those reasons, your commit is not acceptable as it would break > > HEVC encoding for all 3,4,5 gen CPUs and later CPUs with downlevel > > Drivers > > > > What remains is the question whether there's any benefit at all in > > Avoiding the plugin load call. > > > > Does it cost time in ca
Re: [FFmpeg-devel] [PATCH v3 3/4] lavfi: check the validity of formats lists.
Andreas Rheinhardt (12020-08-24): > >>> +if (fmts->all_layouts < fmts->all_counts || > >>> +(!fmts->all_layouts && !fmts->nb_channel_layouts)) { > The above check already contains "|| (!fmts->all_layouts && > !fmts->nb_channel_layouts)". So if everything is zero, you get the error > for an inconsistent generic list. Oh, right, I had considered doing both tests at once, but then separated them for a different message, and forgot. I locally removed the second line above. Sorry. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v3 5/5] doc/encoders.texi: Add documentation for JPEG2000 layers
From: Gautam Ramakrishnan This patch adds documentation for the utility and usage of "layer_rates" option used in the JPEG2000 encoder. --- doc/encoders.texi | 16 1 file changed, 16 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index fd9235a05a..481ad2fb3d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1401,6 +1401,22 @@ Possible values are: @end table Set to @code{lrcp} by default. +@item layer_rates @var{string} +By default, compression is done using the quality metric. This option allows for +compression using compression ratio. The compression ratio for each level could +be specified. The compression ratio of a layer @code{l} species the what ratio of +total file size is contained in the first @code{l} layers. + +Example usage: + +@example +ffmpeg -i input.bmp -c:v jpeg2000 -layer_rates "100,10,1" output.j2k +@end example + +This would compress the image to contain 3 layers, where the data contained in the +first layer would be compressed by 1000 times, compressed by 100 in the first two layers, +and shall contain all data while using all 3 layers. + @end table @section librav1e -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v3 1/5] libavcodec/jpeg2000: Make tag tree functions non static
From: Gautam Ramakrishnan This patch makes the tag_tree_zero() and tag_tree_size() functions non static and callable from other files. --- libavcodec/jpeg2000.c | 12 ++-- libavcodec/jpeg2000.h | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 1aca31ffa4..26e09fbe38 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -39,7 +39,7 @@ /* tag tree routines */ /* allocate the memory for tag tree */ -static int32_t tag_tree_size(int w, int h) +int32_t ff_tag_tree_size(int w, int h) { int64_t res = 0; while (w > 1 || h > 1) { @@ -57,7 +57,7 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h) Jpeg2000TgtNode *res, *t, *t2; int32_t tt_size; -tt_size = tag_tree_size(w, h); +tt_size = ff_tag_tree_size(w, h); t = res = av_mallocz_array(tt_size, sizeof(*t)); if (!res) @@ -82,9 +82,9 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h) return res; } -static void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h) +void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h) { -int i, siz = tag_tree_size(w, h); +int i, siz = ff_tag_tree_size(w, h); for (i = 0; i < siz; i++) { t[i].val = 0; @@ -567,8 +567,8 @@ void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) Jpeg2000Band *band = rlevel->band + bandno; for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++) { Jpeg2000Prec *prec = band->prec + precno; -tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height); -tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height); +ff_tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height); +ff_tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height); for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { Jpeg2000Cblk *cblk = prec->cblk + cblkno; cblk->length = 0; diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index 5b0627c3dc..c3437b02fe 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -290,4 +290,7 @@ static inline int needs_termination(int style, int passno) { return 0; } +int32_t ff_tag_tree_size(int w, int h); +void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h); + #endif /* AVCODEC_JPEG2000_H */ -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v3 3/5] libavcodec/jpeg2000: Modify cleanup
From: Gautam Ramakrishnan This patch makes the ff_jpeg2000_cleanup function take in an extra parameter which indicates whether it is called from the encoder or decoder. --- libavcodec/j2kenc.c | 2 +- libavcodec/jpeg2000.c| 2 +- libavcodec/jpeg2000.h| 2 +- libavcodec/jpeg2000dec.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index d9777fe07f..8699296434 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -1218,7 +1218,7 @@ static void cleanup(Jpeg2000EncoderContext *s) for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ for (compno = 0; compno < s->ncomponents; compno++){ Jpeg2000Component *comp = s->tile[tileno].comp + compno; -ff_jpeg2000_cleanup(comp, codsty); +ff_jpeg2000_cleanup(comp, codsty, 1); } av_freep(&s->tile[tileno].comp); } diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 3d3e7ec313..70c25a0ca2 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -580,7 +580,7 @@ void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) } } -void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) +void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, int isencoder) { int reslevelno, bandno, precno; for (reslevelno = 0; diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index ad58b1ae88..fee9607e86 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -272,7 +272,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty); -void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty); +void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, int isencoder); static inline int needs_termination(int style, int passno) { if (style & JPEG2000_CBLK_BYPASS) { diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 624542c2f8..c5192d007f 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2123,7 +2123,7 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s) Jpeg2000Component *comp = s->tile[tileno].comp + compno; Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno; -ff_jpeg2000_cleanup(comp, codsty); +ff_jpeg2000_cleanup(comp, codsty, 0); } av_freep(&s->tile[tileno].comp); av_freep(&s->tile[tileno].packed_headers); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC PATCH v3 4/5] libavcodec/j2kenc: Support for multiple layers
From: Gautam Ramakrishnan This patch allows setting a compression ratio and to set multiple layers. The user has to input a compression ratio for each layer. The per layer compression ration can be set as follows: -layer_rates "r1,r2,...rn" for to create 'n' layers. --- libavcodec/j2kenc.c | 492 +++ libavcodec/jpeg2000.c| 13 +- libavcodec/jpeg2000.h| 10 + tests/ref/vsynth/vsynth1-jpeg2000| 8 +- tests/ref/vsynth/vsynth1-jpeg2000-97 | 6 +- tests/ref/vsynth/vsynth2-jpeg2000| 8 +- tests/ref/vsynth/vsynth2-jpeg2000-97 | 8 +- tests/ref/vsynth/vsynth3-jpeg2000| 8 +- tests/ref/vsynth/vsynth3-jpeg2000-97 | 8 +- tests/ref/vsynth/vsynth_lena-jpeg2000| 8 +- tests/ref/vsynth/vsynth_lena-jpeg2000-97 | 8 +- 11 files changed, 475 insertions(+), 102 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 8699296434..5f72d924d9 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -32,6 +32,7 @@ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2007, Callum Lerwick + * Copyright (c) 2020, Gautam Ramakrishnan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,6 +101,7 @@ static const int dwt_norms[2][4][10] = { // [dwt_type][band][rlevel] (multiplied typedef struct { Jpeg2000Component *comp; + double *layer_rates; } Jpeg2000Tile; typedef struct { @@ -126,12 +128,16 @@ typedef struct { Jpeg2000QuantStyle qntsty; Jpeg2000Tile *tile; +int layer_rates[100]; +uint8_t compression_rate_enc; ///< Is compression done using compression ratio? int format; int pred; int sop; int eph; int prog; +int nlayers; +char *lr_str; } Jpeg2000EncoderContext; @@ -332,7 +338,7 @@ static int put_cod(Jpeg2000EncoderContext *s) bytestream_put_byte(&s->buf, scod); // Scod // SGcod bytestream_put_byte(&s->buf, s->prog); // progression level -bytestream_put_be16(&s->buf, 1); // num of layers +bytestream_put_be16(&s->buf, s->nlayers); // num of layers if(s->avctx->pix_fmt == AV_PIX_FMT_YUV444P){ bytestream_put_byte(&s->buf, 0); // unspecified }else{ @@ -411,6 +417,31 @@ static uint8_t *put_sot(Jpeg2000EncoderContext *s, int tileno) return psotptr; } +static void compute_rates(Jpeg2000EncoderContext* s) +{ +int i, j; +int layno, compno; +for (i = 0; i < s->numYtiles; i++) { +for (j = 0; j < s->numXtiles; j++) { +Jpeg2000Tile *tile = &s->tile[s->numXtiles * i + j]; +for (compno = 0; compno < s->ncomponents; compno++) { +int tilew = tile->comp[compno].coord[0][1] - tile->comp[compno].coord[0][0]; +int tileh = tile->comp[compno].coord[1][1] - tile->comp[compno].coord[1][0]; +int scale = (compno?1 << s->chroma_shift[0]:1) * (compno?1 << s->chroma_shift[1]:1); +for (layno = 0; layno < s->nlayers; layno++) { +if (s->layer_rates[layno] > 0) { +tile->layer_rates[layno] += (double)(tilew * tileh) * s->ncomponents * s->cbps[compno] / + (double)(s->layer_rates[layno] * 8 * scale); +} else { +tile->layer_rates[layno] = 0.0; +} +} +} +} +} + +} + /** * compute the sizes of tiles, resolution levels, bands, etc. * allocate memory for them @@ -435,6 +466,11 @@ static int init_tiles(Jpeg2000EncoderContext *s) tile->comp = av_mallocz_array(s->ncomponents, sizeof(Jpeg2000Component)); if (!tile->comp) return AVERROR(ENOMEM); + +tile->layer_rates = av_mallocz_array(s->nlayers, sizeof(*tile->layer_rates)); +if (!tile->layer_rates) +return AVERROR(ENOMEM); + for (compno = 0; compno < s->ncomponents; compno++){ Jpeg2000Component *comp = tile->comp + compno; int ret, i, j; @@ -459,6 +495,7 @@ static int init_tiles(Jpeg2000EncoderContext *s) return ret; } } +compute_rates(s); return 0; } @@ -701,6 +738,8 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 } cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len); +cblk->passes[passno].rate -= cblk->passes[passno].flushed_len; + wmsedec += (int64_t)nmsedec << (2*bpno); cblk->passes[passno].disto = wmsedec; @@ -712,8 +751,10 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 cblk->npasses = passno; cbl
[FFmpeg-devel] [RFC PATCH v3 2/5] libavcodec/j2kenc: Fix tag tree coding
From: Gautam Ramakrishnan The implementation of tag tree encoding was incorrect. However, this error was not visible as the current j2k encoder encodes only 1 layer. This patch fixes tag tree coding for JPEG2000 such tag tree coding would work for multi layer encoding. --- libavcodec/j2kenc.c | 41 - libavcodec/jpeg2000.c | 1 + libavcodec/jpeg2000.h | 1 + 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 16863f8e8c..d9777fe07f 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -242,27 +242,34 @@ static void j2k_flush(Jpeg2000EncoderContext *s) static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, int threshold) { Jpeg2000TgtNode *stack[30]; -int sp = 1, curval = 0; -stack[0] = node; +int sp = -1, curval = 0; -node = node->parent; -while(node){ -if (node->vis){ -curval = node->val; -break; -} -node->vis++; -stack[sp++] = node; +while(node->parent){ +stack[++sp] = node; node = node->parent; } -while(--sp >= 0){ -if (stack[sp]->val >= threshold){ -put_bits(s, 0, threshold - curval); -break; + +while (1) { +if (curval > node->temp_val) +node->temp_val = curval; +else { +curval = node->temp_val; } -put_bits(s, 0, stack[sp]->val - curval); -put_bits(s, 1, 1); -curval = stack[sp]->val; +while (curval < threshold) { +if (curval >= node->val) { +if (!node->vis) { +node->vis = 1; +put_bits(s, 1, 1); +} +break; +} +put_bits(s, 0, 1); +curval++; +} +node->temp_val = curval; +if (sp < 0) +break; +node = stack[sp--]; } } diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 26e09fbe38..3d3e7ec313 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -88,6 +88,7 @@ void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h) for (i = 0; i < siz; i++) { t[i].val = 0; +t[i].temp_val = 0; t[i].vis = 0; } } diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index c3437b02fe..ad58b1ae88 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -127,6 +127,7 @@ typedef struct Jpeg2000T1Context { typedef struct Jpeg2000TgtNode { uint8_t val; +uint8_t temp_val; uint8_t vis; struct Jpeg2000TgtNode *parent; } Jpeg2000TgtNode; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 3/4] lavfi: check the validity of formats lists.
Nicolas George: > Andreas Rheinhardt (12020-08-24): >> expects > >> switch to > >> preferred > > Locally fixed. > >>> +if (fmts->all_layouts < fmts->all_counts || >>> +(!fmts->all_layouts && !fmts->nb_channel_layouts)) { >> >> As has already been said in my review of the first version: >> This check doesn't fit to the error message and it also makes the next >> check below dead code. > > I missed the first review, sorry. > > The error message is correct: it is inconsistent to accept all counts > without accepting all layouts. > > And the next test is not dead code: if all_counts and all_layouts are 0, > and nb_channel_layouts is also 0, it is triggered. > > Or am I missing something? > The above check already contains "|| (!fmts->all_layouts && !fmts->nb_channel_layouts)". So if everything is zero, you get the error for an inconsistent generic list. >> >>> +av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n"); >>> +return AVERROR(EINVAL); >>> +} >>> +if (!fmts->all_layouts && !fmts->nb_channel_layouts) { >>> +av_log(log, AV_LOG_ERROR, "Empty channel layout list\n"); >>> +return AVERROR(EINVAL); >>> +} > > Regards, > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 3/4] lavfi: check the validity of formats lists.
Andreas Rheinhardt (12020-08-24): > expects > switch to > preferred Locally fixed. > > +if (fmts->all_layouts < fmts->all_counts || > > +(!fmts->all_layouts && !fmts->nb_channel_layouts)) { > > As has already been said in my review of the first version: > This check doesn't fit to the error message and it also makes the next > check below dead code. I missed the first review, sorry. The error message is correct: it is inconsistent to accept all counts without accepting all layouts. And the next test is not dead code: if all_counts and all_layouts are 0, and nb_channel_layouts is also 0, it is triggered. Or am I missing something? > > > +av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n"); > > +return AVERROR(EINVAL); > > +} > > +if (!fmts->all_layouts && !fmts->nb_channel_layouts) { > > +av_log(log, AV_LOG_ERROR, "Empty channel layout list\n"); > > +return AVERROR(EINVAL); > > +} Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/rtsp: fix infinite loop with udp transport
Ping again. > On Aug 17, 2020, at 8:05 AM, zhilizhao wrote: > > Please help review the patch, thanks! > >> On Aug 6, 2020, at 4:50 PM, quinkbl...@foxmail.com wrote: >> >> From: Zhao Zhili >> >> User report: http://ffmpeg.org/pipermail/ffmpeg-user/2020-August/049494.html >> >> server: >> ./ffmpeg -i test.mp4 -c copy -f rtsp -rtsp_transport udp >> rtsp://localhost:12345/live.sdp >> >> client: >> ./ffmpeg_g -y -rtsp_flags listen -timeout 100 -i >> rtsp://localhost:12345/live.sdp -c copy test.mp4 >> --- >> libavformat/rtsp.c | 5 + >> 1 file changed, 5 insertions(+) >> >> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c >> index 5d8491b74b..0fb9fde6b4 100644 >> --- a/libavformat/rtsp.c >> +++ b/libavformat/rtsp.c >> @@ -2051,6 +2051,11 @@ static int udp_read_packet(AVFormatContext *s, >> RTSPStream **prtsp_st, >>if ((ret = parse_rtsp_message(s)) < 0) { >>return ret; >>} >> +/* Since there is no way to detect eof of udp streams, break >> + * the loop in teardown state to prevent run into infinite. >> + */ >> +if (rt->state == RTSP_STATE_IDLE) >> +return AVERROR_EOF; >>} >> #endif >>} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) { >> -- >> 2.17.1 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/utils: remove always true if()
Ping again. > On Aug 5, 2020, at 11:16 PM, Zhao Zhili wrote: > > Ping for the trivial patch. > >> On Jul 29, 2020, at 1:02 AM, Zhao Zhili wrote: >> >> --- >> libavformat/utils.c | 12 >> 1 file changed, 4 insertions(+), 8 deletions(-) >> >> diff --git a/libavformat/utils.c b/libavformat/utils.c >> index 807d9f10cb..af1cca0c7d 100644 >> --- a/libavformat/utils.c >> +++ b/libavformat/utils.c >> @@ -2543,6 +2543,8 @@ int av_seek_frame(AVFormatContext *s, int stream_index, >> int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, >> int64_t ts, int64_t max_ts, int flags) >> { >> +int ret; >> +int dir; >>if (min_ts > ts || max_ts < ts) >>return -1; >>if (stream_index < -1 || stream_index >= (int)s->nb_streams) >> @@ -2553,7 +2555,6 @@ int avformat_seek_file(AVFormatContext *s, int >> stream_index, int64_t min_ts, >>flags &= ~AVSEEK_FLAG_BACKWARD; >> >>if (s->iformat->read_seek2) { >> -int ret; >>ff_read_frame_flush(s); >> >>if (stream_index == -1 && s->nb_streams == 1) { >> @@ -2582,19 +2583,14 @@ int avformat_seek_file(AVFormatContext *s, int >> stream_index, int64_t min_ts, >> >>// Fall back on old API if new is not implemented but old is. >>// Note the old API has somewhat different semantics. >> -if (s->iformat->read_seek || 1) { >> -int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? >> AVSEEK_FLAG_BACKWARD : 0); >> -int ret = av_seek_frame(s, stream_index, ts, flags | dir); >> +dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? >> AVSEEK_FLAG_BACKWARD : 0); >> +ret = av_seek_frame(s, stream_index, ts, flags | dir); >>if (ret<0 && ts != min_ts && max_ts != ts) { >>ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags >> | dir); >>if (ret >= 0) >>ret = av_seek_frame(s, stream_index, ts, flags | >> (dir^AVSEEK_FLAG_BACKWARD)); >>} >>return ret; >> -} >> - >> -// try some generic seek like seek_frame_generic() but with new ts >> semantics >> -return -1; //unreachable >> } >> >> int avformat_flush(AVFormatContext *s) >> -- >> 2.25.1 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] flvdec: Remove unnecessary initializations
Ping for this trivial change. > On Jul 25, 2020, at 11:24 PM, Zhao Zhili wrote: > > pre_tag_size is always reset by avio_rb32(). For AVFormatContext > start_time, as the document says, "NEVER set this value directly: > It is deduced from the AVStream values." > --- > libavformat/flvdec.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > index 08622739f3..31bdbbd5e9 100644 > --- a/libavformat/flvdec.c > +++ b/libavformat/flvdec.c > @@ -747,7 +747,7 @@ static int flv_read_header(AVFormatContext *s) > int flags; > FLVContext *flv = s->priv_data; > int offset; > -int pre_tag_size = 0; > +int pre_tag_size; > > /* Actual FLV data at 0xe4 in KUX file */ > if(!strcmp(s->iformat->name, "kux")) > @@ -773,7 +773,6 @@ static int flv_read_header(AVFormatContext *s) > av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a > standard flv format, first PreviousTagSize0 always is 0\n"); > } > > -s->start_time = 0; > flv->sum_flv_tag_size = 0; > flv->last_keyframe_stream_index = -1; > > -- > 2.25.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avcodec/cbs_av1: fix handling reference frames on show_existing_frame frames
Implement Section 7.21 "Reference frame loading process" and Section 7.20 "Reference frame update process" for show_existing_frame frames, as required by the definition in Section 7.4 "Decode frame wrapup process". Signed-off-by: James Almer --- libavcodec/cbs_av1_syntax_template.c | 28 +++- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 258779c591..f5ed189be4 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1295,9 +1295,19 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, fb(id_len, display_frame_id); infer(frame_type, frame->frame_type); -if (current->frame_type == AV1_FRAME_KEY) +if (current->frame_type == AV1_FRAME_KEY) { infer(refresh_frame_flags, all_frames); -else + +// Section 7.21 +infer(current_frame_id, frame->frame_id); +priv->upscaled_width = frame->upscaled_width; +priv->frame_width = frame->frame_width; +priv->frame_height= frame->frame_height; +priv->render_width= frame->render_width; +priv->render_height = frame->render_height; +priv->bit_depth = frame->bit_depth; +priv->order_hint = frame->order_hint; +} else infer(refresh_frame_flags, 0); infer(frame_width_minus_1, frame->upscaled_width - 1); @@ -1305,13 +1315,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, infer(render_width_minus_1, frame->render_width - 1); infer(render_height_minus_1, frame->render_height - 1); -priv->upscaled_width = frame->upscaled_width; -priv->frame_width= frame->frame_width; -priv->frame_height = frame->frame_height; -priv->render_width = frame->render_width; -priv->render_height = frame->render_height; - -return 0; +// Section 7.20 +goto update_refs; } fb(2, frame_type); @@ -1573,6 +1578,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, CHECK(FUNC(film_grain_params)(ctx, rw, current)); +update_refs: for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { if (current->refresh_frame_flags & (1 << i)) { priv->ref[i] = (AV1ReferenceFrameState) { @@ -1592,6 +1598,10 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, } } +// Don't print debug log a second time +if (current->show_existing_frame) +return 0; + av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d " "upscaled %d render %dx%d subsample %dx%d " "bitdepth %d tiles %dx%d.\n", priv->order_hint, -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avcodec/cbs_av1: add OrderHint to CodedBitstreamAV1Context
This follows the spec and will come in handy in a following commit. Signed-off-by: James Almer --- libavcodec/cbs_av1.h | 1 + libavcodec/cbs_av1_syntax_template.c | 9 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index 704a231209..913a6e5dea 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -429,6 +429,7 @@ typedef struct CodedBitstreamAV1Context { int operating_point_idc; int bit_depth; +int order_hint; int frame_width; int frame_height; int upscaled_width; diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 28d9ab9817..6a0a105904 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -373,7 +373,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw, for (i = 0; i < AV1_NUM_REF_FRAMES; i++) shifted_order_hints[i] = cur_frame_hint + cbs_av1_get_relative_dist(seq, priv->ref[i].order_hint, - current->order_hint); + priv->order_hint); latest_order_hint = shifted_order_hints[current->last_frame_idx]; earliest_order_hint = shifted_order_hints[current->golden_frame_idx]; @@ -1005,7 +1005,7 @@ static int FUNC(skip_mode_params)(CodedBitstreamContext *ctx, RWContext *rw, for (i = 0; i < AV1_REFS_PER_FRAME; i++) { ref_hint = priv->ref[current->ref_frame_idx[i]].order_hint; dist = cbs_av1_get_relative_dist(seq, ref_hint, - current->order_hint); + priv->order_hint); if (dist < 0) { if (forward_idx < 0 || cbs_av1_get_relative_dist(seq, ref_hint, @@ -1397,6 +1397,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, fb(order_hint_bits, order_hint); else infer(order_hint, 0); +priv->order_hint = current->order_hint; if (frame_is_intra || current->error_resilient_mode) infer(primary_ref_frame, AV1_PRIMARY_REF_NONE); @@ -1586,14 +1587,14 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, .subsampling_x = seq->color_config.subsampling_x, .subsampling_y = seq->color_config.subsampling_y, .bit_depth = priv->bit_depth, -.order_hint = current->order_hint, +.order_hint = priv->order_hint, }; } } av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d " "upscaled %d render %dx%d subsample %dx%d " - "bitdepth %d tiles %dx%d.\n", current->order_hint, + "bitdepth %d tiles %dx%d.\n", priv->order_hint, priv->frame_width, priv->frame_height, priv->upscaled_width, priv->render_width, priv->render_height, seq->color_config.subsampling_x + 1, -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type in show_existing_frame frames earlier
This follows the spec and will come in handy in the next commit. Signed-off-by: James Almer --- libavcodec/cbs_av1_syntax_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 6a0a105904..258779c591 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1294,12 +1294,12 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, if (seq->frame_id_numbers_present_flag) fb(id_len, display_frame_id); -if (frame->frame_type == AV1_FRAME_KEY) +infer(frame_type, frame->frame_type); +if (current->frame_type == AV1_FRAME_KEY) infer(refresh_frame_flags, all_frames); else infer(refresh_frame_flags, 0); -infer(frame_type,frame->frame_type); infer(frame_width_minus_1, frame->upscaled_width - 1); infer(frame_height_minus_1, frame->frame_height - 1); infer(render_width_minus_1, frame->render_width - 1); -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/network: fix comments
--- libavformat/network.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/network.h b/libavformat/network.h index 71347e815b..18e2dd6e5e 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -249,7 +249,7 @@ int ff_is_multicast_address(struct sockaddr *addr); #define POLLING_TIME 100 /// Time in milliseconds between interrupt check /** - * Bind to a file descriptor and poll for a connection. + * Bind an address to a file descriptor and poll for a connection. * * @param fd First argument of bind(). * @param addrSecond argument of bind(). @@ -265,7 +265,7 @@ int ff_listen_bind(int fd, const struct sockaddr *addr, URLContext *h); /** - * Bind to a file descriptor to an address without accepting connections. + * Bind an address to a file descriptor without accepting connections. * @param fd First argument of bind(). * @param addrSecond argument of bind(). * @param addrlen Third argument of bind(). -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 3/4] lavfi: check the validity of formats lists.
Nicolas George: > Part of the code expect valid lists, in particular no duplicates. expects > These tests allow to catch bugs in filters (unlikely but possible) > and to give a clear message when the error comes from the user > ((a)formats) or the application (buffersink). > > If we decide to switch for a more efficient merging algorithm, switch to > possibly sorting the lists, these functions will be the prefered preferred > place for pre-processing, and can be renamed accordingly. > > Signed-off-by: Nicolas George > --- > libavfilter/avfiltergraph.c | 50 ++ > libavfilter/formats.c | 71 + > libavfilter/formats.h | 28 +++ > 3 files changed, 149 insertions(+) > > > Extended commit message. > > > diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c > index 7a85d94971..296920a046 100644 > --- a/libavfilter/avfiltergraph.c > +++ b/libavfilter/avfiltergraph.c > @@ -313,6 +313,53 @@ static void sanitize_channel_layouts(void *log, > AVFilterChannelLayouts *l) > } > } > > +static int filter_link_check_formats(void *log, AVFilterLink *link, > AVFilterFormatsConfig *cfg) > +{ > +int ret; > + > +switch (link->type) { > + > +case AVMEDIA_TYPE_VIDEO: > +if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < > 0) > +return ret; > +break; > + > +case AVMEDIA_TYPE_AUDIO: > +if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < > 0 || > +(ret = ff_formats_check_sample_rates(log, cfg->samplerates)) > < 0 || > +(ret = ff_formats_check_channel_layouts(log, > cfg->channel_layouts)) < 0) > +return ret; > +break; > + > +default: > +av_assert0(!"reached"); > +} > +return 0; > +} > + > +/** > + * Check the validity of the formats / etc. lists set by query_formats(). > + * > + * In particular, check they do not contain any redundant element. > + */ > +static int filter_check_formats(AVFilterContext *ctx) > +{ > +unsigned i; > +int ret; > + > +for (i = 0; i < ctx->nb_inputs; i++) { > +ret = filter_link_check_formats(ctx, ctx->inputs[i], > &ctx->inputs[i]->outcfg); > +if (ret < 0) > +return ret; > +} > +for (i = 0; i < ctx->nb_outputs; i++) { > +ret = filter_link_check_formats(ctx, ctx->outputs[i], > &ctx->outputs[i]->incfg); > +if (ret < 0) > +return ret; > +} > +return 0; > +} > + > static int filter_query_formats(AVFilterContext *ctx) > { > int ret, i; > @@ -329,6 +376,9 @@ static int filter_query_formats(AVFilterContext *ctx) > ctx->name, av_err2str(ret)); > return ret; > } > +ret = filter_check_formats(ctx); > +if (ret < 0) > +return ret; > > for (i = 0; i < ctx->nb_inputs; i++) > sanitize_channel_layouts(ctx, > ctx->inputs[i]->outcfg.channel_layouts); > diff --git a/libavfilter/formats.c b/libavfilter/formats.c > index 695d28ea8e..e575894e77 100644 > --- a/libavfilter/formats.c > +++ b/libavfilter/formats.c > @@ -662,3 +662,74 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, > const char *arg, > > return 0; > } > + > +static int check_list(void *log, const char *name, const AVFilterFormats > *fmts) > +{ > +unsigned i, j; > + > +if (!fmts) > +return 0; > +if (!fmts->nb_formats) { > +av_log(log, AV_LOG_ERROR, "Empty %s list\n", name); > +return AVERROR(EINVAL); > +} > +for (i = 0; i < fmts->nb_formats; i++) { > +for (j = i + 1; j < fmts->nb_formats; j++) { > +if (fmts->formats[i] == fmts->formats[j]) { > +av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name); > +return AVERROR(EINVAL); > +} > +} > +} > +return 0; > +} > + > +int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts) > +{ > +return check_list(log, "pixel format", fmts); > +} > + > +int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts) > +{ > +return check_list(log, "sample format", fmts); > +} > + > +int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts) > +{ > +if (!fmts || !fmts->nb_formats) > +return 0; > +return check_list(log, "sample rate", fmts); > +} > + > +static int layouts_compatible(uint64_t a, uint64_t b) > +{ > +return a == b || > + (KNOWN(a) && !KNOWN(b) && av_get_channel_layout_nb_channels(a) == > FF_LAYOUT2COUNT(b)) || > + (KNOWN(b) && !KNOWN(a) && av_get_channel_layout_nb_channels(b) == > FF_LAYOUT2COUNT(a)); > +} > + > +int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts > *fmts) > +{ > +unsigned i, j; > + > +if (!fmts) > +return 0; > +if (fmts->all_layouts < fmts->all_counts || > +(!
[FFmpeg-devel] [PATCH] avformat/http: set hostname and lower_url buffer size properly
1. The buffer size of lower_url shouldn't be smaller than hostname 2. The maximum length of a DNS name is 255 octets --- libavformat/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 3d25d652d3..9c40a82a5b 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -525,8 +525,8 @@ static int http_listen(URLContext *h, const char *uri, int flags, AVDictionary **options) { HTTPContext *s = h->priv_data; int ret; -char hostname[1024], proto[10]; -char lower_url[100]; +char hostname[256], proto[10]; +char lower_url[512]; const char *lower_proto = "tcp"; int port; av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavfilter/vf_overlay_cuda: Pass the main frame to the output if secondary frame is not available. now filter fails if secondary frame is not available due to e.g secondary
> One observation not related to vf_overlay_cude fix if you don't mind: > even with the fix you proposed if I don't send a single frame into > fs->in[1](i.e secondary stream) I cannot get any output. > This is because consume_from_fifos doesn't honor .before == > EXT_INFINITY and .state == STATE_BOF > let me correct myself: consume_from_fifos doesn't honor .before == EXT_NULL and .state == STATE_BOF > and requires at least one frame for each input. > I cannot say is it WAD or not - just my observation. > When I read a description about EXT_INFINITY I guessed this flag > should force processing other inputs ignoring this one Again let me correct myself here too: I think that if I set fs->in[1].before== EXT_NULL (this is default behavior) framesync should return main frames even if I don't send any frames into fs->in[1]. but consume_from_fifos doesn't honor .before == EXT_NULL and .state == STATE_BOF and this is why it waits for fs->in[1] frames forever. Sorry for bothering you with unrelated question ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type when parsing a show_existing_frame frame
On 8/24/2020 4:57 AM, Xu, Guangxin wrote: > May not related to this patch. > When we have show_existing_frame and the frame_type is key frame, do we need > do "Reference frame update"? I think so, judging by Section 7.4 "Decode frame wrapup process", which says that section 7.20 "Reference frame update process" should be called after parsing a show_existing_frame frame. In any case, this patch was done for the sake of giving the caller a shortcut to read frame properties of the frame referenced by the show_existing_frame frame_header if they needed to, but it was disliked by Ronald, so I'll probably revert it as well as the other inferred values in the previous patch. > >> -Original Message- >> From: ffmpeg-devel On Behalf Of James >> Almer >> Sent: Monday, August 24, 2020 3:24 AM >> To: ffmpeg-devel@ffmpeg.org >> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type when >> parsing a show_existing_frame frame >> >> Signed-off-by: James Almer >> --- >> libavcodec/cbs_av1_syntax_template.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/libavcodec/cbs_av1_syntax_template.c >> b/libavcodec/cbs_av1_syntax_template.c >> index dedd549572..28d9ab9817 100644 >> --- a/libavcodec/cbs_av1_syntax_template.c >> +++ b/libavcodec/cbs_av1_syntax_template.c >> @@ -1299,6 +1299,7 @@ static int >> FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, >> else >> infer(refresh_frame_flags, 0); >> >> +infer(frame_type,frame->frame_type); >> infer(frame_width_minus_1, frame->upscaled_width - 1); >> infer(frame_height_minus_1, frame->frame_height - 1); >> infer(render_width_minus_1, frame->render_width - 1); >> -- >> 2.27.0 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org >> with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware acceleration decoder
On 8/24/2020 5:39 AM, Wang, Fei W wrote: >>> +static int get_tiles_info(AVCodecContext *avctx, >>> + AV1RawTileGroup *tile_group, >>> + uint32_t tile_group_offset) { >>> +AV1DecContext *s = avctx->priv_data; >>> +GetBitContext gb; >>> +uint16_t tile_num, tile_row, tile_col; >>> +uint16_t mi_cols, mi_rows, sb_cols, sb_rows, tile_width_sb, >>> tile_height_sb; >>> +uint32_t size = 0, size_bytes = 0, offset = 0; >>> +int ret = 0; >>> + >>> +if ((ret = init_get_bits8(&gb, >>> + tile_group->tile_data.data, >>> + tile_group->tile_data.data_size)) < 0) { >>> +av_log(avctx, AV_LOG_ERROR, "Fail to initialize bitstream >>> reader.\n"); >>> +return ret; >>> +} >>> + >>> +s->tg_start = tile_group->tg_start; >>> +s->tg_end = tile_group->tg_end; >>> + >>> +if (s->raw_frame_header.uniform_tile_spacing_flag) { >>> +mi_cols = 2 * ((s->raw_seq.max_frame_width_minus_1 + 8) >> 3); >>> +mi_rows = 2 * ((s->raw_seq.max_frame_height_minus_1 + 8) >> 3); >>> +sb_cols = s->raw_seq.use_128x128_superblock ? ((mi_cols + 31) >> 5) >>> +: ((mi_cols + 15) >> >>> 4); >>> +sb_rows = s->raw_seq.use_128x128_superblock ? ((mi_rows + 31) >> 5) >>> +: ((mi_rows + 15) >> >>> 4); >>> +tile_width_sb = (sb_cols + (1 << >>> s->raw_frame_header.tile_cols_log2) >>> + -1) >> s->raw_frame_header.tile_cols_log2; >>> +tile_height_sb = (sb_rows + (1 << >>> s->raw_frame_header.tile_rows_log2) >>> + -1) >> s->raw_frame_header.tile_rows_log2; >> Maybe cbs read should always fill the width/height_in_sbs arrays so that all >> the >> special casing for uniform_spacing_flag in this function isn't needed? It >> would >> be trivial to add it there. > @James Almer, how do you think of this? Currently, cbs_av1 read > width/height_in_sbs_minus_1 directly from bitstream. But if > uniform_spacing_flag is 1, > the 2 values may need some calculation like here does. Mark suggested a solution in the form of a patch as a reply to his own email in this same thread. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware acceleration decoder
On 8/24/2020 3:57 AM, Wang, Fei W wrote: > > >> -Original Message- >> From: ffmpeg-devel On Behalf Of James >> Almer >> Sent: Friday, August 21, 2020 10:43 PM >> To: ffmpeg-devel@ffmpeg.org >> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware >> acceleration decoder >> >> On 8/21/2020 2:29 AM, Fei Wang wrote: >>> This av1 decoder is now only used for av1 hardware acceleration >>> decoder. Consider it can be extend to a local decoder like hevc or vp9 >>> in the future, so define its name as "av1" and put it into external >>> libraries codec list. >>> >>> Signed-off-by: Fei Wang >>> --- >>> Changelog | 1 + >>> configure | 1 + >>> libavcodec/Makefile| 1 + >>> libavcodec/allcodecs.c | 1 + >>> libavcodec/av1dec.c| 746 >> + >>> libavcodec/av1dec.h| 89 + >>> libavcodec/version.h | 2 +- >>> 7 files changed, 840 insertions(+), 1 deletion(-) create mode 100644 >>> libavcodec/av1dec.c create mode 100644 libavcodec/av1dec.h >>> >>> diff --git a/Changelog b/Changelog >>> index 1efc768387..3ff88cc12f 100644 >>> --- a/Changelog >>> +++ b/Changelog >>> @@ -14,6 +14,7 @@ version : >>> - ADPCM Argonaut Games encoder >>> - Argonaut Games ASF muxer >>> - AV1 Low overhead bitstream format demuxer >>> +- AV1 decoder (Hardware acceleration used only) >>> >>> >>> version 4.3: >>> diff --git a/configure b/configure >>> index 6faff9bc7b..ef71e47c4e 100755 >>> --- a/configure >>> +++ b/configure >>> @@ -2685,6 +2685,7 @@ atrac3al_decoder_select="mdct" >>> atrac3p_decoder_select="mdct sinewin" >>> atrac3pal_decoder_select="mdct sinewin" >>> atrac9_decoder_select="mdct" >>> +av1_decoder_select="cbs_av1" >>> avrn_decoder_select="exif jpegtables" >>> bink_decoder_select="blockdsp hpeldsp" >>> binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" >>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile index >>> 3431ba2dca..2371039bd2 100644 >>> --- a/libavcodec/Makefile >>> +++ b/libavcodec/Makefile >>> @@ -764,6 +764,7 @@ OBJS-$(CONFIG_ZLIB_DECODER)+= lcldec.o >>> OBJS-$(CONFIG_ZLIB_ENCODER)+= lclenc.o >>> OBJS-$(CONFIG_ZMBV_DECODER)+= zmbv.o >>> OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o >>> +OBJS-$(CONFIG_AV1_DECODER) += av1dec.o >>> >>> # (AD)PCM decoders/encoders >>> OBJS-$(CONFIG_PCM_ALAW_DECODER) += pcm.o >>> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index >>> 4bd830e5d0..00799d3431 100644 >>> --- a/libavcodec/allcodecs.c >>> +++ b/libavcodec/allcodecs.c >>> @@ -761,6 +761,7 @@ extern AVCodec ff_idf_decoder; >>> * above is available */ >>> extern AVCodec ff_aac_mf_encoder; >>> extern AVCodec ff_ac3_mf_encoder; >>> +extern AVCodec ff_av1_decoder; >>> extern AVCodec ff_h263_v4l2m2m_encoder; extern AVCodec >>> ff_libaom_av1_decoder; extern AVCodec ff_libopenh264_encoder; diff >>> --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c new file mode 100644 >>> index 00..ab88ed987a >>> --- /dev/null >>> +++ b/libavcodec/av1dec.c >>> @@ -0,0 +1,746 @@ >>> +/* >>> + * AV1video decoder >>> + * >>> + * This file is part of FFmpeg. >>> + * >>> + * FFmpeg is free software; you can redistribute it and/or >>> + * modify it under the terms of the GNU Lesser General Public >>> + * License as published by the Free Software Foundation; either >>> + * version 2.1 of the License, or (at your option) any later version. >>> + * >>> + * FFmpeg is distributed in the hope that it will be useful, >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >>> + * Lesser General Public License for more details. >>> + * >>> + * You should have received a copy of the GNU Lesser General Public >>> + * License along with FFmpeg; if not, write to the Free Software >>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >>> +02110-1301 USA */ >>> + >>> +#include "avcodec.h" >>> +#include "get_bits.h" >>> +#include "hwconfig.h" >>> +#include "internal.h" >>> +#include "profiles.h" >>> +#include "thread.h" >>> +#include "videodsp.h" >>> +#include "libavutil/avassert.h" >>> +#include "libavutil/pixdesc.h" >>> + >>> +#include "av1dec.h" >>> +#include "libavformat/av1.h" >>> + >>> +static void setup_past_independence(AV1Frame *f) { >>> +f->loop_filter_delta_enabled = 1; >>> + >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_INTRA] = 1; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST] = 0; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST2] = 0; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST3] = 0; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_GOLDEN] = -1; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_BWDREF] = 0; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF2] = -1; >>> +f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF] = -1; >>> + >>> +f->loop_filter_mode_deltas[0] = 0; >>>
[FFmpeg-devel] [PATCH v2 2/2] avformat/mpegtsenc: reindent the code
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/mpegtsenc.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 5a9e6fd..1559ce6 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1744,24 +1744,24 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) av_log(s, AV_LOG_ERROR, "AAC bitstream not in ADTS format " "and extradata missing\n"); } else { -av_init_packet(&pkt2); -pkt2.data = pkt->data; -pkt2.size = pkt->size; -av_assert0(pkt->dts != AV_NOPTS_VALUE); -pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base); - -ret = avio_open_dyn_buf(&ts_st->amux->pb); -if (ret < 0) -return ret; - -ret = av_write_frame(ts_st->amux, &pkt2); -if (ret < 0) { -ffio_free_dyn_buf(&ts_st->amux->pb); -return ret; -} -size= avio_close_dyn_buf(ts_st->amux->pb, &data); -ts_st->amux->pb = NULL; -buf = data; +av_init_packet(&pkt2); +pkt2.data = pkt->data; +pkt2.size = pkt->size; +av_assert0(pkt->dts != AV_NOPTS_VALUE); +pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base); + +ret = avio_open_dyn_buf(&ts_st->amux->pb); +if (ret < 0) +return ret; + +ret = av_write_frame(ts_st->amux, &pkt2); +if (ret < 0) { +ffio_free_dyn_buf(&ts_st->amux->pb); +return ret; +} +size= avio_close_dyn_buf(ts_st->amux->pb, &data); +ts_st->amux->pb = NULL; +buf = data; } } } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/mpegtsenc.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 61fdd09..5a9e6fd 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -487,6 +487,10 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) /* write optional descriptors here */ switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_AUDIO: +if (codec_id == AV_CODEC_ID_AC3) +put_registration_descriptor(&q, MKTAG('A', 'C', '-', '3')); +else if (codec_id == AV_CODEC_ID_EAC3) +put_registration_descriptor(&q, MKTAG('E', 'A', 'C', '3')); if (ts->flags & MPEGTS_FLAG_SYSTEM_B) { if (codec_id == AV_CODEC_ID_AC3) { DVBAC3Descriptor *dvb_ac3_desc = ts_st->dvb_ac3_desc; -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fate: remove "-v 0" from ffprobe tests.
Nicolas George (12020-08-21): > From e3a3ad20b1ecb2c167ba30ed6b6ced36f146f4b5 Mon Sep 17 00:00:00 2001 > From: Nicolas George > Date: Fri, 21 Aug 2020 13:03:50 +0200 > Subject: [PATCH] fate: remove "-v 0" from ffprobe tests. > > Signed-off-by: Nicolas George > --- > tests/fate-run.sh | 26 +- > 1 file changed, 13 insertions(+), 13 deletions(-) Pushed. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 8/8] RFC: editing HDR properties in H.265 metadata BSF
> On 23 Aug 2020, at 23:33, Mark Thompson wrote: > > --- > Setting HDR properties is a useful feature, but it's very unclear what we > want it to actually look like to the user. Not all encoders and decoders > support it, so it's essentially required that the implementation happen at > the bitstream filter level so that we can support all codecs in the same way. > This is several patches mashed together to invite comments on a bitstream > filter approach. Mastering display data behaves similarly to color_range, color_primaries, color_trc and colorspace in that some formats allow use to set it on frame, some on the stream, some on the container but it is a property of the contained pictures. I notice that color data can be set per frame and per stream already and I don’t fully understand how these interact if converting between data in frame (e.g HEVC SEI in stream in hev1) or data in header (e.g. MOV mdcv tag or HEVC SEI in hvc1 format). Content light level data is a little different as it describes the stream in which the image is contained and ffmpeg image filters would affect it. It it however still a property of the whole stream. I guess my question is how to provide a good experience converting between hvc1, hev1, prores in movs, av1 etc etc when the data has to be moved between frame and stream. > > […] > > Thoughts invited on any of this. As you point out MDCV and CLLI are relevant to so many codecs and container formats that anything with hevc_ etc would be confusing as adapting configs for different formats would require extra work (e.g. read from av1, write to hevc bitstream filters). I an pretty new to FFMPEG to please ignore any of this that makes no sense :) Harry ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 4/4] lavfi/buffersink: remove redundant channel layouts.
The channel_layouts and channel_counts options set what buffersink is supposed to accept. If channel_counts contains 2, then stereo is already accepted, there is no point in having it in channel_layouts too. This was not properly documented until now, so only print a warning. Signed-off-by: Nicolas George --- libavfilter/buffersink.c | 24 1 file changed, 24 insertions(+) Faster algorithm. diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 76a46f6678..9338969bf1 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -62,6 +62,29 @@ typedef struct BufferSinkContext { #define NB_ITEMS(list) (list ## _size / sizeof(*list)) +static void cleanup_redundant_layouts(AVFilterContext *ctx) +{ +BufferSinkContext *buf = ctx->priv; +int nb_layouts = NB_ITEMS(buf->channel_layouts); +int nb_counts = NB_ITEMS(buf->channel_counts); +uint64_t counts = 0; +int i, lc, n; + +for (i = 0; i < nb_counts; i++) +if (buf->channel_counts[i] < 64) +counts |= 1 << buf->channel_counts[i]; +for (i = lc = 0; i < nb_layouts; i++) { +n = av_get_channel_layout_nb_channels(buf->channel_layouts[i]); +if (n < 64 && (counts & (1 << n))) +av_log(ctx, AV_LOG_WARNING, + "Removing channel layout 0x%"PRIx64", redundant with %d channels\n", + buf->channel_layouts[i], n); +else +buf->channel_layouts[lc++] = buf->channel_layouts[i]; +} +buf->channel_layouts_size = lc * sizeof(*buf->channel_layouts); +} + int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame) { return av_buffersink_get_frame_flags(ctx, frame, 0); @@ -253,6 +276,7 @@ static int asink_query_formats(AVFilterContext *ctx) if (buf->channel_layouts_size || buf->channel_counts_size || buf->all_channel_counts) { +cleanup_redundant_layouts(ctx); for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++) if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) return ret; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 3/4] lavfi: check the validity of formats lists.
Part of the code expect valid lists, in particular no duplicates. These tests allow to catch bugs in filters (unlikely but possible) and to give a clear message when the error comes from the user ((a)formats) or the application (buffersink). If we decide to switch for a more efficient merging algorithm, possibly sorting the lists, these functions will be the prefered place for pre-processing, and can be renamed accordingly. Signed-off-by: Nicolas George --- libavfilter/avfiltergraph.c | 50 ++ libavfilter/formats.c | 71 + libavfilter/formats.h | 28 +++ 3 files changed, 149 insertions(+) Extended commit message. diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 7a85d94971..296920a046 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -313,6 +313,53 @@ static void sanitize_channel_layouts(void *log, AVFilterChannelLayouts *l) } } +static int filter_link_check_formats(void *log, AVFilterLink *link, AVFilterFormatsConfig *cfg) +{ +int ret; + +switch (link->type) { + +case AVMEDIA_TYPE_VIDEO: +if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < 0) +return ret; +break; + +case AVMEDIA_TYPE_AUDIO: +if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < 0 || +(ret = ff_formats_check_sample_rates(log, cfg->samplerates)) < 0 || +(ret = ff_formats_check_channel_layouts(log, cfg->channel_layouts)) < 0) +return ret; +break; + +default: +av_assert0(!"reached"); +} +return 0; +} + +/** + * Check the validity of the formats / etc. lists set by query_formats(). + * + * In particular, check they do not contain any redundant element. + */ +static int filter_check_formats(AVFilterContext *ctx) +{ +unsigned i; +int ret; + +for (i = 0; i < ctx->nb_inputs; i++) { +ret = filter_link_check_formats(ctx, ctx->inputs[i], &ctx->inputs[i]->outcfg); +if (ret < 0) +return ret; +} +for (i = 0; i < ctx->nb_outputs; i++) { +ret = filter_link_check_formats(ctx, ctx->outputs[i], &ctx->outputs[i]->incfg); +if (ret < 0) +return ret; +} +return 0; +} + static int filter_query_formats(AVFilterContext *ctx) { int ret, i; @@ -329,6 +376,9 @@ static int filter_query_formats(AVFilterContext *ctx) ctx->name, av_err2str(ret)); return ret; } +ret = filter_check_formats(ctx); +if (ret < 0) +return ret; for (i = 0; i < ctx->nb_inputs; i++) sanitize_channel_layouts(ctx, ctx->inputs[i]->outcfg.channel_layouts); diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 695d28ea8e..e575894e77 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -662,3 +662,74 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg, return 0; } + +static int check_list(void *log, const char *name, const AVFilterFormats *fmts) +{ +unsigned i, j; + +if (!fmts) +return 0; +if (!fmts->nb_formats) { +av_log(log, AV_LOG_ERROR, "Empty %s list\n", name); +return AVERROR(EINVAL); +} +for (i = 0; i < fmts->nb_formats; i++) { +for (j = i + 1; j < fmts->nb_formats; j++) { +if (fmts->formats[i] == fmts->formats[j]) { +av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name); +return AVERROR(EINVAL); +} +} +} +return 0; +} + +int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts) +{ +return check_list(log, "pixel format", fmts); +} + +int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts) +{ +return check_list(log, "sample format", fmts); +} + +int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts) +{ +if (!fmts || !fmts->nb_formats) +return 0; +return check_list(log, "sample rate", fmts); +} + +static int layouts_compatible(uint64_t a, uint64_t b) +{ +return a == b || + (KNOWN(a) && !KNOWN(b) && av_get_channel_layout_nb_channels(a) == FF_LAYOUT2COUNT(b)) || + (KNOWN(b) && !KNOWN(a) && av_get_channel_layout_nb_channels(b) == FF_LAYOUT2COUNT(a)); +} + +int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts) +{ +unsigned i, j; + +if (!fmts) +return 0; +if (fmts->all_layouts < fmts->all_counts || +(!fmts->all_layouts && !fmts->nb_channel_layouts)) { +av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n"); +return AVERROR(EINVAL); +} +if (!fmts->all_layouts && !fmts->nb_channel_layouts) { +av_log(log, AV_LOG_ERROR, "Empty channel layout list\n"); +return AVERROR(EINVAL); +} +for (i = 0; i < fmts->nb_channel_layouts; i++) { +
[FFmpeg-devel] [PATCH v3 1/4] lavfi: regroup formats lists in a single structure.
It will allow to refernce it as a whole without clunky macros. Most of the changes have been automatically made with sed: sed -i ' s/-> *in_formats/->incfg.formats/g; s/-> *out_formats/->outcfg.formats/g; s/-> *in_channel_layouts/->incfg.channel_layouts/g; s/-> *out_channel_layouts/->outcfg.channel_layouts/g; s/-> *in_samplerates/->incfg.samplerates/g; s/-> *out_samplerates/->outcfg.samplerates/g; ' src/libavfilter/*(.) Signed-off-by: Nicolas George --- Rebased on top of recent commits and resolved conflicts. libavfilter/aeval.c| 4 +- libavfilter/af_afir.c | 8 +- libavfilter/af_agate.c | 10 +- libavfilter/af_aiir.c | 2 +- libavfilter/af_amerge.c| 12 +- libavfilter/af_anequalizer.c | 14 +- libavfilter/af_aresample.c | 12 +- libavfilter/af_asetrate.c | 2 +- libavfilter/af_channelmap.c| 4 +- libavfilter/af_channelsplit.c | 4 +- libavfilter/af_hdcd.c | 4 +- libavfilter/af_headphone.c | 8 +- libavfilter/af_join.c | 4 +- libavfilter/af_ladspa.c| 6 +- libavfilter/af_loudnorm.c | 4 +- libavfilter/af_lv2.c | 6 +- libavfilter/af_pan.c | 4 +- libavfilter/af_resample.c | 12 +- libavfilter/af_sidechaincompress.c | 10 +- libavfilter/af_sofalizer.c | 4 +- libavfilter/af_surround.c | 4 +- libavfilter/avf_abitscope.c| 8 +- libavfilter/avf_ahistogram.c | 8 +- libavfilter/avf_aphasemeter.c | 14 +- libavfilter/avf_avectorscope.c | 8 +- libavfilter/avf_concat.c | 12 +- libavfilter/avf_showcqt.c | 8 +- libavfilter/avf_showfreqs.c| 8 +- libavfilter/avf_showspatial.c | 8 +- libavfilter/avf_showspectrum.c | 8 +- libavfilter/avf_showvolume.c | 8 +- libavfilter/avf_showwaves.c| 8 +- libavfilter/avfilter.c | 30 ++-- libavfilter/avfilter.h | 60 +--- libavfilter/avfiltergraph.c| 216 ++--- libavfilter/f_drawgraph.c | 2 +- libavfilter/f_ebur128.c| 14 +- libavfilter/f_graphmonitor.c | 2 +- libavfilter/formats.c | 6 +- libavfilter/src_movie.c| 8 +- libavfilter/tests/filtfmts.c | 6 +- libavfilter/vaapi_vpp.c| 4 +- libavfilter/vaf_spectrumsynth.c| 10 +- libavfilter/vf_alphamerge.c| 6 +- libavfilter/vf_ciescope.c | 4 +- libavfilter/vf_colorspace.c| 4 +- libavfilter/vf_coreimage.m | 6 +- libavfilter/vf_elbg.c | 4 +- libavfilter/vf_extractplanes.c | 12 +- libavfilter/vf_fieldmatch.c| 6 +- libavfilter/vf_fieldorder.c| 4 +- libavfilter/vf_histogram.c | 12 +- libavfilter/vf_hwdownload.c| 4 +- libavfilter/vf_hwmap.c | 4 +- libavfilter/vf_hwupload.c | 4 +- libavfilter/vf_hwupload_cuda.c | 4 +- libavfilter/vf_lut2.c | 4 +- libavfilter/vf_mergeplanes.c | 4 +- libavfilter/vf_overlay.c | 6 +- libavfilter/vf_overlay_qsv.c | 4 +- libavfilter/vf_palettegen.c| 4 +- libavfilter/vf_paletteuse.c| 6 +- libavfilter/vf_remap.c | 8 +- libavfilter/vf_scale.c | 4 +- libavfilter/vf_showpalette.c | 4 +- libavfilter/vf_vectorscope.c | 12 +- libavfilter/vf_vpp_qsv.c | 4 +- libavfilter/vf_waveform.c | 14 +- libavfilter/vf_yadif_cuda.c| 4 +- libavfilter/vf_zscale.c| 4 +- 70 files changed, 386 insertions(+), 364 deletions(-) diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c index c7a8cd6550..4c62c98097 100644 --- a/libavfilter/aeval.c +++ b/libavfilter/aeval.c @@ -362,7 +362,7 @@ static int aeval_query_formats(AVFilterContext *ctx) // inlink supports any channel layout layouts = ff_all_channel_counts(); -if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) +if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; if (eval->same_chlayout) { @@ -376,7 +376,7 @@ static int aeval_query_formats(AVFilterContext *ctx) eval->out_channel_layout ? eval->out_channel_layout : FF_COUNT2LAYOUT(eval->nb_channels))) < 0) return ret; -if ((ret = ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts)) < 0) +if ((ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 4e76bda4a3..11db199a24 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -731,7 +731,7 @@ static int query_formats(AVFilterContext *ctx)
[FFmpeg-devel] [PATCH v3 2/4] lavfi/formats: simplify a macro parameters.
Signed-off-by: Nicolas George --- libavfilter/formats.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) Rebased on top of recent commits and resolved conflicts. diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 0a351d4174..695d28ea8e 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -535,15 +535,15 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) FORMATS_CHANGEREF(oldref, newref); } -#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref_fn, unref_fn) \ +#define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn) \ int count = 0, i; \ \ if (!fmts) \ return AVERROR(ENOMEM); \ \ for (i = 0; i < ctx->nb_inputs; i++) { \ -if (ctx->inputs[i] && !ctx->inputs[i]->out_fmts) { \ -int ret = ref_fn(fmts, &ctx->inputs[i]->out_fmts); \ +if (ctx->inputs[i] && !ctx->inputs[i]->outcfg.fmts) { \ +int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \ if (ret < 0) { \ return ret; \ } \ @@ -551,8 +551,8 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) } \ } \ for (i = 0; i < ctx->nb_outputs; i++) { \ -if (ctx->outputs[i] && !ctx->outputs[i]->in_fmts) { \ -int ret = ref_fn(fmts, &ctx->outputs[i]->in_fmts); \ +if (ctx->outputs[i] && !ctx->outputs[i]->incfg.fmts) { \ +int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \ if (ret < 0) { \ return ret; \ } \ @@ -567,16 +567,16 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) return 0; int ff_set_common_channel_layouts(AVFilterContext *ctx, - AVFilterChannelLayouts *layouts) + AVFilterChannelLayouts *channel_layouts) { -SET_COMMON_FORMATS(ctx, layouts, incfg.channel_layouts, outcfg.channel_layouts, +SET_COMMON_FORMATS(ctx, channel_layouts, ff_channel_layouts_ref, ff_channel_layouts_unref); } int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates) { -SET_COMMON_FORMATS(ctx, samplerates, incfg.samplerates, outcfg.samplerates, +SET_COMMON_FORMATS(ctx, samplerates, ff_formats_ref, ff_formats_unref); } @@ -587,7 +587,7 @@ int ff_set_common_samplerates(AVFilterContext *ctx, */ int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) { -SET_COMMON_FORMATS(ctx, formats, incfg.formats, outcfg.formats, +SET_COMMON_FORMATS(ctx, formats, ff_formats_ref, ff_formats_unref); } -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 2/2] libavformat/mxfenc: color_range should be inclusive
> On 24 Aug 2020, at 09:30, Tomas Härdin wrote: > > tor 2020-08-20 klockan 14:58 +0100 skrev Harry Mallon: >> MXF CDCI color range was being set to (1> for full range but it should be (1 > a valid value. > > Grammar here is a bit strange. Do you mean 0 is a valid value? Looks OK > besides this Sorry, it is meant to read ‘as 0 is a valid value’. Shall I change in a new version? Thanks for being attentive and speedy with my patches btw. Sending things into FFMPEG has been pretty painless. :) Harry. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] web/documentation: Updated list of FFmpeg books
On Mon, 24 Aug 2020 14:11:00 +1000 "Steven Liu" wrote: > > A few things: > > > > 1. Is the second link to the author's website really necessary? > the Chinaffmpeg link is added by me > that because it’s only Chinese Font version, > and there have lots link about that book in China, eg, jd.com, taobao.com, > dangdang.com > maybe of this link is not static link. > and the price of the book some times will be changed in different time. > and i’m writing second edition, so only one link is ok here. Ah, I didn't mean that, I meant in the patch there's the link to the store: https://www.amazon.com/FFmpeg-Beginners-Audio-Youtube-Social-ebook/dp/B087GYV15Y/ then there's also the link to the author's website: http://johnriselvato.com/ I was asking if the second link was necessary. Imo, just the first is enough. Zane ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware acceleration decoder
> -Original Message- > From: ffmpeg-devel On Behalf Of Mark > Thompson > Sent: Sunday, August 23, 2020 6:01 AM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add av1 hardware > acceleration decoder > > On 21/08/2020 06:29, Fei Wang wrote: > > This av1 decoder is now only used for av1 hardware acceleration > > decoder. Consider it can be extend to a local decoder like hevc or vp9 > > in the future, so define its name as "av1" and put it into external > > libraries codec list. > > > > Signed-off-by: Fei Wang > > --- > > Changelog | 1 + > > configure | 1 + > > libavcodec/Makefile| 1 + > > libavcodec/allcodecs.c | 1 + > > libavcodec/av1dec.c| 746 > + > > libavcodec/av1dec.h| 89 + > > libavcodec/version.h | 2 +- > > 7 files changed, 840 insertions(+), 1 deletion(-) > > create mode 100644 libavcodec/av1dec.c > > create mode 100644 libavcodec/av1dec.h > > > > diff --git a/Changelog b/Changelog > > index 1efc768387..3ff88cc12f 100644 > > --- a/Changelog > > +++ b/Changelog > > @@ -14,6 +14,7 @@ version : > > - ADPCM Argonaut Games encoder > > - Argonaut Games ASF muxer > > - AV1 Low overhead bitstream format demuxer > > +- AV1 decoder (Hardware acceleration used only) > > > > > > version 4.3: > > diff --git a/configure b/configure > > index 6faff9bc7b..ef71e47c4e 100755 > > --- a/configure > > +++ b/configure > > @@ -2685,6 +2685,7 @@ atrac3al_decoder_select="mdct" > > atrac3p_decoder_select="mdct sinewin" > > atrac3pal_decoder_select="mdct sinewin" > > atrac9_decoder_select="mdct" > > +av1_decoder_select="cbs_av1" > > avrn_decoder_select="exif jpegtables" > > bink_decoder_select="blockdsp hpeldsp" > > binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile index > > 3431ba2dca..2371039bd2 100644 > > --- a/libavcodec/Makefile > > +++ b/libavcodec/Makefile > > @@ -764,6 +764,7 @@ OBJS-$(CONFIG_ZLIB_DECODER)+= lcldec.o > > OBJS-$(CONFIG_ZLIB_ENCODER)+= lclenc.o > > OBJS-$(CONFIG_ZMBV_DECODER)+= zmbv.o > > OBJS-$(CONFIG_ZMBV_ENCODER)+= zmbvenc.o > > +OBJS-$(CONFIG_AV1_DECODER) += av1dec.o > > > > # (AD)PCM decoders/encoders > > OBJS-$(CONFIG_PCM_ALAW_DECODER) += pcm.o > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index > > 4bd830e5d0..00799d3431 100644 > > --- a/libavcodec/allcodecs.c > > +++ b/libavcodec/allcodecs.c > > @@ -761,6 +761,7 @@ extern AVCodec ff_idf_decoder; > >* above is available */ > > extern AVCodec ff_aac_mf_encoder; > > extern AVCodec ff_ac3_mf_encoder; > > +extern AVCodec ff_av1_decoder; > > extern AVCodec ff_h263_v4l2m2m_encoder; > > extern AVCodec ff_libaom_av1_decoder; > > extern AVCodec ff_libopenh264_encoder; diff --git > > a/libavcodec/av1dec.c b/libavcodec/av1dec.c new file mode 100644 index > > 00..ab88ed987a > > --- /dev/null > > +++ b/libavcodec/av1dec.c > > @@ -0,0 +1,746 @@ > > +/* > > + * AV1video decoder > > + * > > + * This file is part of FFmpeg. > > + * > > + * FFmpeg is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * FFmpeg is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with FFmpeg; if not, write to the Free Software > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > > +02110-1301 USA */ > > + > > +#include "avcodec.h" > > +#include "get_bits.h" > > +#include "hwconfig.h" > > +#include "internal.h" > > +#include "profiles.h" > > +#include "thread.h" > > +#include "videodsp.h" > > +#include "libavutil/avassert.h" > > +#include "libavutil/pixdesc.h" > > + > > +#include "av1dec.h" > > +#include "libavformat/av1.h" > > + > > +static void setup_past_independence(AV1Frame *f) { > > +f->loop_filter_delta_enabled = 1; > > + > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_INTRA] = 1; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST] = 0; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST2] = 0; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_LAST3] = 0; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_GOLDEN] = -1; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_BWDREF] = 0; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF2] = -1; > > +f->loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF] = -1; > > + > > +f->loop_filter_mode_deltas[0] = 0; > > +f->loop_fi
Re: [FFmpeg-devel] [PATCH v5 2/2] libavformat/mxfenc: color_range should be inclusive
tor 2020-08-20 klockan 14:58 +0100 skrev Harry Mallon: > MXF CDCI color range was being set to (1for full range but it should be (1 a valid value. Grammar here is a bit strange. Do you mean 0 is a valid value? Looks OK besides this /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 1/2] avformat/mxfdec: Read video range from CDCIEssenceDescriptor
tor 2020-08-20 klockan 14:58 +0100 skrev Harry Mallon: > * Capture black_ref, white_ref and color_range and recognise > full and narrow range. > > Signed-off-by: Harry Mallon > --- > libavformat/mxfdec.c | 37 ++ > tests/ref/fate/mxf-probe-dnxhd | 2 +- > tests/ref/fate/mxf-probe-dv25 | 2 +- > 3 files changed, 39 insertions(+), 2 deletions(-) > > [...] > +static enum AVColorRange mxf_get_color_range(MXFContext *mxf, MXFDescriptor > *descriptor) > +{ > +if (descriptor->black_ref_level || descriptor->white_ref_level || > descriptor->color_range) { > +/* CDCI range metadata */ > +if (!descriptor->component_depth) > +return AVCOL_RANGE_UNSPECIFIED; > +if (descriptor->black_ref_level == 0 && > +descriptor->white_ref_level == ((1- 1) && > +(descriptor->color_range== (1 || > + descriptor->color_range== ((1 - 1))) > +return AVCOL_RANGE_JPEG; > +if (descriptor->component_depth >= 8 && > +descriptor->black_ref_level == (1 > <<(descriptor->component_depth - 4)) && > +descriptor->white_ref_level == > (235<<(descriptor->component_depth - 8)) && > +descriptor->color_range == > ((14<<(descriptor->component_depth - 4)) + 1)) > +return AVCOL_RANGE_MPEG; > +avpriv_request_sample(mxf->fc, "Unrecognized CDCI color range (color > diff range %d, b %d, w %d, depth %d)", > + descriptor->color_range, > descriptor->black_ref_level, > + descriptor->white_ref_level, > descriptor->component_depth); > +} Looks OK. Sorry about the late reply. I'll push tomorrow if there isn't more feedback /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type when parsing a show_existing_frame frame
May not related to this patch. When we have show_existing_frame and the frame_type is key frame, do we need do "Reference frame update"? > -Original Message- > From: ffmpeg-devel On Behalf Of James > Almer > Sent: Monday, August 24, 2020 3:24 AM > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type when > parsing a show_existing_frame frame > > Signed-off-by: James Almer > --- > libavcodec/cbs_av1_syntax_template.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavcodec/cbs_av1_syntax_template.c > b/libavcodec/cbs_av1_syntax_template.c > index dedd549572..28d9ab9817 100644 > --- a/libavcodec/cbs_av1_syntax_template.c > +++ b/libavcodec/cbs_av1_syntax_template.c > @@ -1299,6 +1299,7 @@ static int > FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, > else > infer(refresh_frame_flags, 0); > > +infer(frame_type,frame->frame_type); > infer(frame_width_minus_1, frame->upscaled_width - 1); > infer(frame_height_minus_1, frame->frame_height - 1); > infer(render_width_minus_1, frame->render_width - 1); > -- > 2.27.0 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".