[FFmpeg-cvslog] avfilter/vf_bilateral: simplify code a little

2020-07-18 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri Jul 17 20:29:48 
2020 +0200| [fa8345cf059394544387e1a47016dec109379a8a] | committer: Paul B Mahol

avfilter/vf_bilateral: simplify code a little

Make alpha_ calculation faster.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa8345cf059394544387e1a47016dec109379a8a
---

 libavfilter/vf_bilateral.c | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c
index 3025b49ae5..59e008ca1d 100644
--- a/libavfilter/vf_bilateral.c
+++ b/libavfilter/vf_bilateral.c
@@ -41,6 +41,7 @@ typedef struct BilateralContext {
 int planewidth[4];
 int planeheight[4];
 
+float alpha;
 float range_table[65536];
 
 float *img_out_f;
@@ -99,10 +100,11 @@ static int config_input(AVFilterLink *inlink)
 
 s->depth = desc->comp[0].depth;
 inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1));
+s->alpha = expf(-sqrtf(2.f) / s->sigmaS);
 
 //compute a lookup table
 for (int i = 0; i < (1 << s->depth); i++)
-s->range_table[i] = expf(-i * inv_sigma_range);
+s->range_table[i] = s->alpha * expf(-i * inv_sigma_range);
 
 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, 
desc->log2_chroma_w);
 s->planewidth[0] = s->planewidth[3] = inlink->w;
@@ -144,10 +146,10 @@ static void bilateral_##name(BilateralContext *s, const 
uint8_t *ssrc, uint8_t *
 float *map_factor_a = s->map_factor_a, *map_factor_b = s->map_factor_b;
 \
 float *slice_factor_a = s->slice_factor_a, *slice_factor_b = 
s->slice_factor_b; \
 float *line_factor_a = s->line_factor_a, *line_factor_b = 
s->line_factor_b; \
-float *range_table = s->range_table;   
 \
-float alpha = expf(-sqrtf(2.f) / sigma_spatial);   
 \
+const float *range_table = s->range_table; 
 \
+const float alpha = s->alpha;  
 \
 float ypr, ycr, *ycy, *ypy, *xcy, fp, fc;  
 \
-float inv_alpha_ = 1 - alpha;  
 \
+const float inv_alpha_ = 1.f - alpha;  
 \
 float *ycf, *ypf, *xcf, *in_factor;
 \
 const type *tcy, *tpy; 
   \
 int h1;
   \
@@ -165,14 +167,13 @@ static void bilateral_##name(BilateralContext *s, const 
uint8_t *ssrc, uint8_t *
 *temp_factor_x++ = fp = 1; 
   \

   \
 for (int x = 1; x < width; x++) {  
   \
-float weight, alpha_;  
   \
+float alpha_;  
   \
 int range_dist;
   \
 type tcr = *texture_x++;   
   \
 type dr = abs(tcr - tpr);  
   \

   \
 range_dist = dr;   
   \
-weight = range_table[range_dist];  
   \
-alpha_ = weight*alpha; 
   \
+alpha_ = range_table[range_dist];  
   \
 *temp_x++ = ycr = inv_alpha_*(*in_x++) + alpha_*ypr;   
   \
 tpr = tcr; 
   \
 ypr = ycr; 
   \
@@ -190,8 +191,7 @@ static void bilateral_##name(BilateralContext *s, const 
uint8_t *ssrc, uint8_t *
 type tcr = *--texture_x;   
   \
 type dr = abs(tcr - tpr);  
   \
 int range_dist = dr;   
   \
-float weight = range_table[range_dist];
   \
-float alpha_ = weight * alpha; 
   \
+float alpha_ = range_table[range_dist];
   \
  

[FFmpeg-cvslog] avformat/au: Remove redundant av_freep()

2020-07-18 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 13 17:18:48 2020 +0200| [84340497c03d34ce6902d210b8a20b848c37ce98] | 
committer: Andreas Rheinhardt

avformat/au: Remove redundant av_freep()

This av_freep(&key) in conjunction with the fact that the loop condition
checks for key != NULL was equivalent to a av_freep(&key) + a break
immediately thereafter. But given that there is an av_freep(&key)
directly after the loop, the av_freep(&key) is unnecessary and the break
can also be added explicitly.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84340497c03d34ce6902d210b8a20b848c37ce98
---

 libavformat/au.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/au.c b/libavformat/au.c
index b419c9ed95..c4a32ff76c 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -107,11 +107,11 @@ static int au_read_annotation(AVFormatContext *s, int 
size)
 av_log(s, AV_LOG_ERROR, "Memory error while parsing AU 
metadata.\n");
 } else {
 av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
-for (i = 0; i < FF_ARRAY_ELEMS(keys) && key != NULL; i++) {
+for (i = 0; i < FF_ARRAY_ELEMS(keys); i++) {
 if (av_strcasecmp(keys[i], key) == 0) {
 av_dict_set(&(s->metadata), keys[i], value, 
AV_DICT_DONT_STRDUP_VAL);
-av_freep(&key);
 value = NULL;
+break;
 }
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avformat/au: Avoid allocation for metadata string

2020-07-18 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 13 19:31:46 2020 +0200| [1998d1d6af98f31e9ddeead4893efad8144357be] | 
committer: Andreas Rheinhardt

avformat/au: Avoid allocation for metadata string

When there are potentially annotation (i.e. metadata) fields to write,
au_get_annotations() is called to produce a string with them. To do so,
it uses an AVBPrint which is finalized to create the string. This is
wasteful, because it always leads to an allocation even if the string
actually fits into the internal buffer of the AVBPrint. This commit
changes this by making au_get_annotations() modify an AVBPrint that
resides on the stack of the caller (i.e. of au_write_header()).

Furthermore, the AVBPrint is now checked for truncation; limiting
the allocations implicit in the AVBPrint allowed to offload the overflow
checks. Notice that these were not correct before: The size parameter of
avio_write() is an int, yet the string in the AVBPrint was allowed to
grow bigger than INT_MAX. And if the length of the string was so near
UINT_MAX that the length + 32 overflowed, the old code would write the
first eight bytes of the string and nothing more, leading to an invalid
file.

Finally, the special case in which the metadata dictionary of the
AVFormatContext is empty (in which case one still has to write eight
binary zeroes) is now no longer treated specially, because this case
no longer incurs any allocation.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1998d1d6af98f31e9ddeead4893efad8144357be
---

 libavformat/au.c | 50 +++---
 1 file changed, 19 insertions(+), 31 deletions(-)

diff --git a/libavformat/au.c b/libavformat/au.c
index a8906a9db7..c09f4da4c9 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -35,8 +35,6 @@
 
 /* if we don't know the size in advance */
 #define AU_UNKNOWN_SIZE ((uint32_t)(~0))
-/* the specification requires an annotation field of at least eight bytes */
-#define AU_DEFAULT_HEADER_SIZE (24+8)
 
 static const AVCodecTag codec_au_tags[] = {
 { AV_CODEC_ID_PCM_MULAW,  1 },
@@ -241,7 +239,7 @@ typedef struct AUContext {
 
 #include "rawenc.h"
 
-static int au_get_annotations(AVFormatContext *s, char **buffer)
+static int au_get_annotations(AVFormatContext *s, AVBPrint *annotations)
 {
 static const char keys[][7] = {
 "Title",
@@ -253,21 +251,19 @@ static int au_get_annotations(AVFormatContext *s, char 
**buffer)
 int cnt = 0;
 AVDictionary *m = s->metadata;
 AVDictionaryEntry *t = NULL;
-AVBPrint bprint;
-
-av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
 
 for (int i = 0; i < FF_ARRAY_ELEMS(keys); i++) {
 t = av_dict_get(m, keys[i], NULL, 0);
 if (t != NULL) {
 if (cnt++)
-av_bprint_chars(&bprint, '\n', 1);
-av_bprintf(&bprint, "%s=%s", keys[i], t->value);
+av_bprint_chars(annotations, '\n', 1);
+av_bprintf(annotations, "%s=%s", keys[i], t->value);
 }
 }
-/* pad with 0's */
-av_bprint_chars(&bprint, '\0', 8);
-return av_bprint_finalize(&bprint, buffer);
+/* The specification requires the annotation field to be zero-terminated
+ * and its length to be a multiple of eight, so pad with 0's */
+av_bprint_chars(annotations, '\0', 8);
+return av_bprint_is_complete(annotations) ? 0 : AVERROR(ENOMEM);
 }
 
 static int au_write_header(AVFormatContext *s)
@@ -276,9 +272,7 @@ static int au_write_header(AVFormatContext *s)
 AUContext *au = s->priv_data;
 AVIOContext *pb = s->pb;
 AVCodecParameters *par = s->streams[0]->codecpar;
-char *annotations = NULL;
-
-au->header_size = AU_DEFAULT_HEADER_SIZE;
+AVBPrint annotations;
 
 if (s->nb_streams != 1) {
 av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
@@ -291,30 +285,24 @@ static int au_write_header(AVFormatContext *s)
 return AVERROR(EINVAL);
 }
 
-if (av_dict_count(s->metadata) > 0) {
-ret = au_get_annotations(s, &annotations);
-if (ret < 0)
-return ret;
-if (annotations != NULL) {
-au->header_size = (24 + strlen(annotations) + 8) & ~7;
-if (au->header_size < AU_DEFAULT_HEADER_SIZE)
-au->header_size = AU_DEFAULT_HEADER_SIZE;
-}
-}
+av_bprint_init(&annotations, 0, INT_MAX - 24);
+ret = au_get_annotations(s, &annotations);
+if (ret < 0)
+goto fail;
+au->header_size = 24 + annotations.len & ~7;
+
 ffio_wfourcc(pb, ".snd");   /* magic number */
 avio_wb32(pb, au->header_size); /* header size */
 avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
 avio_wb32(pb, par->codec_tag);  /* codec ID */
 avio_wb32(pb, par->sample_rate);
 avio_wb32(pb, par->channels);
-if (annotations != NULL) {
-avio_write(pb, annotations, au->header_siz

[FFmpeg-cvslog] avformat/au: Simplify writing string into AVBPrint

2020-07-18 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 13 20:04:26 2020 +0200| [c2e17e8d8446abbd5dcfebab1e63024837677ca7] | 
committer: Andreas Rheinhardt

avformat/au: Simplify writing string into AVBPrint

by using av_bprintf() instead of several av_bprint_append().

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c2e17e8d8446abbd5dcfebab1e63024837677ca7
---

 libavformat/au.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/au.c b/libavformat/au.c
index c4a32ff76c..a8906a9db7 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -262,13 +262,11 @@ static int au_get_annotations(AVFormatContext *s, char 
**buffer)
 if (t != NULL) {
 if (cnt++)
 av_bprint_chars(&bprint, '\n', 1);
-av_bprint_append_data(&bprint, keys[i], strlen(keys[i]));
-av_bprint_chars(&bprint, '=', 1);
-av_bprint_append_data(&bprint, t->value, strlen(t->value));
+av_bprintf(&bprint, "%s=%s", keys[i], t->value);
 }
 }
 /* pad with 0's */
-av_bprint_append_data(&bprint, "\0\0\0\0\0\0\0\0", 8);
+av_bprint_chars(&bprint, '\0', 8);
 return av_bprint_finalize(&bprint, buffer);
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avformat/au: Store strings instead of pointers to strings in array

2020-07-18 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 13 17:13:51 2020 +0200| [8d3556b7a3f89f5dd621c3359f8690cf38796db7] | 
committer: Andreas Rheinhardt

avformat/au: Store strings instead of pointers to strings in array

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d3556b7a3f89f5dd621c3359f8690cf38796db7
---

 libavformat/au.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavformat/au.c b/libavformat/au.c
index f92863e400..b419c9ed95 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -68,13 +68,13 @@ static int au_probe(const AVProbeData *p)
 
 static int au_read_annotation(AVFormatContext *s, int size)
 {
-static const char * keys[] = {
+static const char keys[][7] = {
 "title",
 "artist",
 "album",
 "track",
 "genre",
-NULL };
+};
 AVIOContext *pb = s->pb;
 enum { PARSE_KEY, PARSE_VALUE, PARSE_FINISHED } state = PARSE_KEY;
 char c;
@@ -107,7 +107,7 @@ static int au_read_annotation(AVFormatContext *s, int size)
 av_log(s, AV_LOG_ERROR, "Memory error while parsing AU 
metadata.\n");
 } else {
 av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
-for (i = 0; keys[i] != NULL && key != NULL; i++) {
+for (i = 0; i < FF_ARRAY_ELEMS(keys) && key != NULL; i++) {
 if (av_strcasecmp(keys[i], key) == 0) {
 av_dict_set(&(s->metadata), keys[i], value, 
AV_DICT_DONT_STRDUP_VAL);
 av_freep(&key);
@@ -243,14 +243,13 @@ typedef struct AUContext {
 
 static int au_get_annotations(AVFormatContext *s, char **buffer)
 {
-static const char * keys[] = {
+static const char keys[][7] = {
 "Title",
 "Artist",
 "Album",
 "Track",
 "Genre",
-NULL };
-int i;
+};
 int cnt = 0;
 AVDictionary *m = s->metadata;
 AVDictionaryEntry *t = NULL;
@@ -258,7 +257,7 @@ static int au_get_annotations(AVFormatContext *s, char 
**buffer)
 
 av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
 
-for (i = 0; keys[i] != NULL; i++) {
+for (int i = 0; i < FF_ARRAY_ELEMS(keys); i++) {
 t = av_dict_get(m, keys[i], NULL, 0);
 if (t != NULL) {
 if (cnt++)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] doc/http: Update HTTP protocol options

2020-07-18 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Fri Jul 17 
10:59:05 2020 +0800| [68c56082d3888d7c1aba9f518ee9ad73850b7e31] | committer: 
Jun Zhao

doc/http: Update HTTP protocol options

remove the timeout option docs part for HTTP protocol and add
auth_type option part.

Reviewed-by: Gyan Doshi 
Signed-off-by: Jun Zhao 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68c56082d3888d7c1aba9f518ee9ad73850b7e31
---

 doc/protocols.texi | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 64ad3f05d6..7b3df96fda 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -392,11 +392,6 @@ string describing the libavformat build. ("Lavf/")
 @item user-agent
 This is a deprecated option, you can use user_agent instead it.
 
-@item timeout
-Set timeout in microseconds of socket I/O operations used by the underlying 
low level
-operation. By default it is set to -1, which means that the timeout is
-not specified.
-
 @item reconnect_at_eof
 If set then eof is treated like an error and causes reconnection, this is 
useful
 for live / endless streams.
@@ -481,6 +476,28 @@ Send an Expect: 100-continue header for POST. If set to 1 
it will send, if set
 to 0 it won't, if set to -1 it will try to send if it is applicable. Default
 value is -1.
 
+@item auth_type
+
+Set HTTP authentication type. No option for Digest, since this method requires
+getting nonce parameters from the server first and can't be used straight away 
like
+Basic.
+
+@table @option
+@item none
+Choose the HTTP authentication type automatically. This is the default.
+@item basic
+
+Choose the HTTP basic authentication.
+
+Basic authentication sends a Base64-encoded string that contains a user name 
and password
+for the client. Base64 is not a form of encryption and should be considered 
the same as
+sending the user name and password in clear text (Base64 is a reversible 
encoding).
+If a resource needs to be protected, strongly consider using an authentication 
scheme
+other than basic authentication. HTTPS/TLS should be used with basic 
authentication.
+Without these additional security enhancements, basic authentication should 
not be used
+to protect sensitive or valuable information.
+@end table
+
 @end table
 
 @subsection HTTP Cookies

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avformat/apm: fix variable/structure names and cosmetics

2020-07-18 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Mon Jul  6 
18:50:52 2020 +1000| [91a9f86edf5ce8508e471146aafaa3c5fb1d5fbc] | committer: 
Zane van Iperen

avformat/apm: fix variable/structure names and cosmetics

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91a9f86edf5ce8508e471146aafaa3c5fb1d5fbc
---

 libavformat/apm.c | 100 --
 1 file changed, 51 insertions(+), 49 deletions(-)

diff --git a/libavformat/apm.c b/libavformat/apm.c
index 8d655d0a33..0d88e1099a 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -44,37 +44,37 @@ typedef struct APMState {
 int32_t saved_l;
 } APMState;
 
-typedef struct APMVS12Chunk {
+typedef struct APMExtraData {
 uint32_tmagic;
 uint32_tfile_size;
 uint32_tdata_size;
 uint32_tunk1;
 uint32_tunk2;
 APMStatestate;
-uint32_tpad[7];
+uint32_tunk3[7];
 uint32_tdata;
-} APMVS12Chunk;
+} APMExtraData;
 
-static void apm_parse_vs12(APMVS12Chunk *vs12, const uint8_t *buf)
+static void apm_parse_extradata(APMExtraData *ext, const uint8_t *buf)
 {
-vs12->magic = AV_RL32(buf + 0);
-vs12->file_size = AV_RL32(buf + 4);
-vs12->data_size = AV_RL32(buf + 8);
-vs12->unk1  = AV_RL32(buf + 12);
-vs12->unk2  = AV_RL32(buf + 16);
-
-vs12->state.has_saved   = AV_RL32(buf + 20);
-vs12->state.predictor_r = AV_RL32(buf + 24);
-vs12->state.step_index_r= AV_RL32(buf + 28);
-vs12->state.saved_r = AV_RL32(buf + 32);
-vs12->state.predictor_l = AV_RL32(buf + 36);
-vs12->state.step_index_l= AV_RL32(buf + 40);
-vs12->state.saved_l = AV_RL32(buf + 44);
-
-for (int i = 0; i < FF_ARRAY_ELEMS(vs12->pad); i++)
-vs12->pad[i]= AV_RL32(buf + 48 + (i * 4));
-
-vs12->data  = AV_RL32(buf + 76);
+ext->magic  = AV_RL32(buf + 0);
+ext->file_size  = AV_RL32(buf + 4);
+ext->data_size  = AV_RL32(buf + 8);
+ext->unk1   = AV_RL32(buf + 12);
+ext->unk2   = AV_RL32(buf + 16);
+
+ext->state.has_saved= AV_RL32(buf + 20);
+ext->state.predictor_r  = AV_RL32(buf + 24);
+ext->state.step_index_r = AV_RL32(buf + 28);
+ext->state.saved_r  = AV_RL32(buf + 32);
+ext->state.predictor_l  = AV_RL32(buf + 36);
+ext->state.step_index_l = AV_RL32(buf + 40);
+ext->state.saved_l  = AV_RL32(buf + 44);
+
+for (int i = 0; i < FF_ARRAY_ELEMS(ext->unk3); i++)
+ext->unk3[i]= AV_RL32(buf + 48 + (i * 4));
+
+ext->data   = AV_RL32(buf + 76);
 }
 
 static int apm_probe(const AVProbeData *p)
@@ -98,7 +98,8 @@ static int apm_read_header(AVFormatContext *s)
 {
 int64_t ret;
 AVStream *st;
-APMVS12Chunk vs12;
+APMExtraData extradata;
+AVCodecParameters *par;
 uint8_t buf[APM_FILE_EXTRADATA_SIZE];
 
 if (!(st = avformat_new_stream(s, NULL)))
@@ -111,67 +112,68 @@ static int apm_read_header(AVFormatContext *s)
 if (avio_rl16(s->pb) != APM_TAG_CODEC)
 return AVERROR_INVALIDDATA;
 
-st->codecpar->channels  = avio_rl16(s->pb);
-st->codecpar->sample_rate   = avio_rl32(s->pb);
+par = st->codecpar;
+par->channels  = avio_rl16(s->pb);
+par->sample_rate   = avio_rl32(s->pb);
 
 /* Skip the bitrate, it's usually wrong anyway. */
 if ((ret = avio_skip(s->pb, 4)) < 0)
 return ret;
 
-st->codecpar->block_align   = avio_rl16(s->pb);
-st->codecpar->bits_per_coded_sample = avio_rl16(s->pb);
+par->block_align   = avio_rl16(s->pb);
+par->bits_per_coded_sample = avio_rl16(s->pb);
 
 if (avio_rl32(s->pb) != APM_FILE_EXTRADATA_SIZE)
 return AVERROR_INVALIDDATA;
 
 /* I've never seen files greater than this. */
-if (st->codecpar->sample_rate > 44100)
+if (par->sample_rate > 44100)
 return AVERROR_INVALIDDATA;
 
-if (st->codecpar->bits_per_coded_sample != 4)
+if (par->bits_per_coded_sample != 4)
 return AVERROR_INVALIDDATA;
 
-if (st->codecpar->channels == 2)
-st->codecpar->channel_layout= AV_CH_LAYOUT_STEREO;
-else if (st->codecpar->channels == 1)
-st->codecpar->channel_layout= AV_CH_LAYOUT_MONO;
+if (par->channels == 2)
+par->channel_layout= AV_CH_LAYOUT_STEREO;
+else if (par->channels == 1)
+par->channel_layout= AV_CH_LAYOUT_MONO;
 else
 return AVERROR_INVALIDDATA;
 
-st->codecpar->codec_type= AVMEDIA_TYPE_AUDIO;
-st->codecpar->codec_id  = AV_CODEC_ID_ADPCM_IMA_APM;
-st->codecpar->format= AV_SAMPLE_FMT_S16;
-st->codecpar->bits_per_raw_sample   = 16;
-st->codecpar->bit_rate  = st->codecpar->channels *
-  st->codecpa

[FFmpeg-cvslog] avformat/apm: use the entire APMState structure as extradata

2020-07-18 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Wed Jul  8 
00:42:09 2020 +1000| [1b0a0da63a279804df04292cf452b2acdd87b687] | committer: 
Zane van Iperen

avformat/apm: use the entire APMState structure as extradata

Is the "actual" codec extradata instead of the hand-crafted one
from the previous revision.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b0a0da63a279804df04292cf452b2acdd87b687
---

 libavformat/apm.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavformat/apm.c b/libavformat/apm.c
index 4158b81457..8d655d0a33 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -26,6 +26,7 @@
 
 #define APM_FILE_HEADER_SIZE18
 #define APM_FILE_EXTRADATA_SIZE 80
+#define APM_EXTRADATA_SIZE  28
 
 #define APM_MAX_READ_SIZE   4096
 
@@ -160,13 +161,11 @@ static int apm_read_header(AVFormatContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
-if ((ret = ff_alloc_extradata(st->codecpar, 16)) < 0)
+if ((ret = ff_alloc_extradata(st->codecpar, APM_EXTRADATA_SIZE)) < 0)
 return ret;
 
-AV_WL32(st->codecpar->extradata +  0, vs12.state.predictor_l);
-AV_WL32(st->codecpar->extradata +  4, vs12.state.step_index_l);
-AV_WL32(st->codecpar->extradata +  8, vs12.state.predictor_r);
-AV_WL32(st->codecpar->extradata + 12, vs12.state.step_index_r);
+/* Use the entire state as extradata. */
+memcpy(st->codecpar->extradata, buf + 20, APM_EXTRADATA_SIZE);
 
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 st->start_time  = 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avformat/apm: read header correctly

2020-07-18 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Tue Jun 30 
10:44:39 2020 +1000| [3bf1be210150b435c51c7c8eb8fd05a1fca08814] | committer: 
Zane van Iperen

avformat/apm: read header correctly

The leading WAVEFORMATEX in .APM files is malformed:
* The nAvgBytesPerSec field is wrong, and
* sizeof(cbSize) is 4 instead of 2.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3bf1be210150b435c51c7c8eb8fd05a1fca08814
---

 libavformat/Makefile |  2 +-
 libavformat/apm.c| 50 --
 2 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 26af859a28..a4113fe644 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -93,7 +93,7 @@ OBJS-$(CONFIG_AMRWB_DEMUXER) += amr.o
 OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
 OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
-OBJS-$(CONFIG_APM_DEMUXER)   += apm.o riffdec.o
+OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
diff --git a/libavformat/apm.c b/libavformat/apm.c
index dc59c16562..4158b81457 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -21,12 +21,12 @@
  */
 #include "avformat.h"
 #include "internal.h"
-#include "riff.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define APM_FILE_HEADER_SIZE20
-#define APM_VS12_CHUNK_SIZE 76
+#define APM_FILE_HEADER_SIZE18
+#define APM_FILE_EXTRADATA_SIZE 80
+
 #define APM_MAX_READ_SIZE   4096
 
 #define APM_TAG_CODEC   0x2000
@@ -51,6 +51,7 @@ typedef struct APMVS12Chunk {
 uint32_tunk2;
 APMStatestate;
 uint32_tpad[7];
+uint32_tdata;
 } APMVS12Chunk;
 
 static void apm_parse_vs12(APMVS12Chunk *vs12, const uint8_t *buf)
@@ -71,6 +72,8 @@ static void apm_parse_vs12(APMVS12Chunk *vs12, const uint8_t 
*buf)
 
 for (int i = 0; i < FF_ARRAY_ELEMS(vs12->pad); i++)
 vs12->pad[i]= AV_RL32(buf + 48 + (i * 4));
+
+vs12->data  = AV_RL32(buf + 76);
 }
 
 static int apm_probe(const AVProbeData *p)
@@ -95,24 +98,37 @@ static int apm_read_header(AVFormatContext *s)
 int64_t ret;
 AVStream *st;
 APMVS12Chunk vs12;
-uint8_t buf[APM_VS12_CHUNK_SIZE];
+uint8_t buf[APM_FILE_EXTRADATA_SIZE];
 
 if (!(st = avformat_new_stream(s, NULL)))
 return AVERROR(ENOMEM);
 
-/* The header starts with a WAVEFORMATEX */
-if ((ret = ff_get_wav_header(s, s->pb, st->codecpar, APM_FILE_HEADER_SIZE, 
0)) < 0)
+/*
+ * This is 98% a WAVEFORMATEX, but there's something screwy with the 
extradata
+ * that ff_get_wav_header() can't (and shouldn't) handle properly.
+ */
+if (avio_rl16(s->pb) != APM_TAG_CODEC)
+return AVERROR_INVALIDDATA;
+
+st->codecpar->channels  = avio_rl16(s->pb);
+st->codecpar->sample_rate   = avio_rl32(s->pb);
+
+/* Skip the bitrate, it's usually wrong anyway. */
+if ((ret = avio_skip(s->pb, 4)) < 0)
 return ret;
 
-if (st->codecpar->bits_per_coded_sample != 4)
+st->codecpar->block_align   = avio_rl16(s->pb);
+st->codecpar->bits_per_coded_sample = avio_rl16(s->pb);
+
+if (avio_rl32(s->pb) != APM_FILE_EXTRADATA_SIZE)
 return AVERROR_INVALIDDATA;
 
-if (st->codecpar->codec_tag != APM_TAG_CODEC)
+/* I've never seen files greater than this. */
+if (st->codecpar->sample_rate > 44100)
 return AVERROR_INVALIDDATA;
 
-/* ff_get_wav_header() does most of the work, but we need to fix a few 
things. */
-st->codecpar->codec_id  = AV_CODEC_ID_ADPCM_IMA_APM;
-st->codecpar->codec_tag = 0;
+if (st->codecpar->bits_per_coded_sample != 4)
+return AVERROR_INVALIDDATA;
 
 if (st->codecpar->channels == 2)
 st->codecpar->channel_layout= AV_CH_LAYOUT_STEREO;
@@ -121,31 +137,29 @@ static int apm_read_header(AVFormatContext *s)
 else
 return AVERROR_INVALIDDATA;
 
+st->codecpar->codec_type= AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id  = AV_CODEC_ID_ADPCM_IMA_APM;
 st->codecpar->format= AV_SAMPLE_FMT_S16;
 st->codecpar->bits_per_raw_sample   = 16;
 st->codecpar->bit_rate  = st->codecpar->channels *
   st->codecpar->sample_rate *
   st->codecpar->bits_per_coded_sample;
 
-if ((ret = avio_read(s->pb, buf, APM_VS12_CHUNK_SIZE)) < 0)
+if ((ret = avio_read(s->pb, buf, APM_FILE_EXTRADATA_SIZE)) < 0)
 return ret;
-else if (ret != APM_VS12_CHUNK_SIZE)
+else if (ret != APM_FILE_EXTRADATA_SIZE)
 return AVERROR(EIO);
 
 apm_parse_vs12(&vs12, buf);

[FFmpeg-cvslog] lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure

2020-07-18 Thread Linjie Fu
ffmpeg | branch: master | Linjie Fu  | Mon May 11 14:32:42 
2020 +0800| [489c5db0791f39518775b12eef6d48276c17f96f] | committer: Linjie Fu

lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure

VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS is added to in the latest
libva (1.8.0) which matches the hardware behaviour:

/** \brief Driver supports any number of rows per slice but they must
*be the same for all slices except for the last one, which must be
*equal or smaller to the previous slices.
*/

And VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS is kind of deprecated for iHD
since it's somehow introduced in [1] which is misleading from what we
actually handles.

[1]

Signed-off-by: Linjie Fu 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=489c5db0791f39518775b12eef6d48276c17f96f
---

 libavcodec/vaapi_encode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index e39db20200..d6a986d5f0 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1900,6 +1900,9 @@ static av_cold int 
vaapi_encode_init_slice_structure(AVCodecContext *avctx)
 req_slices = avctx->slices;
 }
 if (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS ||
+#if VA_CHECK_VERSION(1, 8, 0)
+slice_structure & VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS ||
+#endif
 slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) {
 ctx->nb_slices  = req_slices;
 ctx->slice_size = ctx->slice_block_rows / ctx->nb_slices;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".