[FFmpeg-devel] [PATCH 2/2] trace_headers: Update documentation

2018-11-30 Thread Andreas Rheinhardt
It also supports AV1 and (M)JPEG.

Signed-off-by: Andreas Rheinhardt 
---
 doc/bitstream_filters.texi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 15c578aa8a..b779265f58 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -632,7 +632,8 @@ Log trace output containing all syntax elements in the 
coded stream
 headers (everything above the level of individual coded blocks).
 This can be useful for debugging low-level stream issues.
 
-Supports H.264, H.265, MPEG-2 and VP9.
+Supports AV1, H.264, H.265, (M)JPEG, MPEG-2 and VP9, but depending
+on the build only a subset of these may be available.
 
 @section truehd_core
 
-- 
2.19.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] cbs_h265: Fix Time Code SEI syntax

2018-11-30 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
https://trac.ffmpeg.org/ticket/4141#comment:9 contains a sample
containing Time Code SEI messages. Parsing it currently fails
because counting_type is detected as out of range. Of course, it is not.

 libavcodec/cbs_h265_syntax_template.c | 56 ++-
 1 file changed, 30 insertions(+), 26 deletions(-)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 0a430df23a..f1e1bb0e7e 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1955,36 +1955,40 @@ static int FUNC(sei_time_code)(CodedBitstreamContext 
*ctx, RWContext *rw,
 u(2, num_clock_ts, 1, 3);
 
 for (i = 0; i < current->num_clock_ts; i++) {
-flags(units_field_based_flag[i], 1, i);
-us(5, counting_type[i], 0, 6,1, i);
-flags(full_timestamp_flag[i],1, i);
-flags(discontinuity_flag[i], 1, i);
-flags(cnt_dropped_flag[i],   1, i);
-
-us(9, n_frames[i], 0, MAX_UINT_BITS(9), 1, i);
-
-if (current->full_timestamp_flag[i]) {
-us(6, seconds_value[i], 0, 59, 1, i);
-us(6, minutes_value[i], 0, 59, 1, i);
-us(5, hours_value[i],   0, 23, 1, i);
-} else {
-flags(seconds_flag[i], 1, i);
-if (current->seconds_flag[i]) {
+flags(clock_timestamp_flag[i],   1, i);
+
+if (current->clock_timestamp_flag[i]) {
+flags(units_field_based_flag[i], 1, i);
+us(5, counting_type[i], 0, 6,1, i);
+flags(full_timestamp_flag[i],1, i);
+flags(discontinuity_flag[i], 1, i);
+flags(cnt_dropped_flag[i],   1, i);
+
+us(9, n_frames[i], 0, MAX_UINT_BITS(9), 1, i);
+
+if (current->full_timestamp_flag[i]) {
 us(6, seconds_value[i], 0, 59, 1, i);
-flags(minutes_flag[i], 1, i);
-if (current->minutes_flag[i]) {
-us(6, minutes_value[i], 0, 59, 1, i);
-flags(hours_flag[i], 1, i);
-if (current->hours_flag[i])
-us(5, hours_value[i], 0, 23, 1, i);
+us(6, minutes_value[i], 0, 59, 1, i);
+us(5, hours_value[i],   0, 23, 1, i);
+} else {
+flags(seconds_flag[i], 1, i);
+if (current->seconds_flag[i]) {
+us(6, seconds_value[i], 0, 59, 1, i);
+flags(minutes_flag[i], 1, i);
+if (current->minutes_flag[i]) {
+us(6, minutes_value[i], 0, 59, 1, i);
+flags(hours_flag[i], 1, i);
+if (current->hours_flag[i])
+us(5, hours_value[i], 0, 23, 1, i);
+}
 }
 }
-}
 
-us(5, time_offset_length[i], 0, 31, 1, i);
-if (current->time_offset_length[i] > 0)
-us(current->time_offset_length[i], time_offset_value[i],
-   0, MAX_UINT_BITS(current->time_offset_length[i]), 1, i);
+us(5, time_offset_length[i], 0, 31, 1, i);
+if (current->time_offset_length[i] > 0)
+us(current->time_offset_length[i], time_offset_value[i],
+   0, MAX_UINT_BITS(current->time_offset_length[i]), 1, i);
+}
 }
 
 return 0;
-- 
2.19.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/samidec: don't error on empty packets

2018-11-30 Thread Rodger Combs
No change to output; just prevents error spam
---
 libavcodec/samidec.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
index e32f238c62..7ea67b5597 100644
--- a/libavcodec/samidec.c
+++ b/libavcodec/samidec.c
@@ -38,6 +38,7 @@ typedef struct {
 int readorder;
 } SAMIContext;
 
+// Returns 1 if valid content was decoded; 0 if none; <0 if error
 static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
 {
 SAMIContext *sami = avctx->priv_data;
@@ -84,7 +85,7 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const 
char *src)
 while (av_isspace(*p))
 p++;
 if (!strncmp(p, "", 6)) {
-ret = -1;
+ret = 0;
 goto end;
 }
 
@@ -126,6 +127,8 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, 
const char *src)
 goto end;
 av_bprintf(>full, "%s", sami->encoded_content.str);
 
+ret = 1;
+
 end:
 av_free(dupsrc);
 return ret;
@@ -142,10 +145,12 @@ static int sami_decode_frame(AVCodecContext *avctx,
 int ret = sami_paragraph_to_ass(avctx, ptr);
 if (ret < 0)
 return ret;
-// TODO: pass escaped sami->encoded_source.str as source
-ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, 
NULL);
-if (ret < 0)
-return ret;
+if (ret > 0) {
+// TODO: pass escaped sami->encoded_source.str as source
+ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, 
NULL, NULL);
+if (ret < 0)
+return ret;
+}
 }
 *got_sub_ptr = sub->num_rects > 0;
 return avpkt->size;
-- 
2.19.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/hevcdec: Check for overlapping slices

2018-11-30 Thread Michael Niedermayer
On Sat, Nov 24, 2018 at 02:51:34AM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 10108/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6222384351674368
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/hevcdec.c | 4 
>  libavcodec/hevcdec.h | 1 +
>  2 files changed, 5 insertions(+)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/mips: [loongson] refine optimization in h264_chroma.

2018-11-30 Thread Michael Niedermayer
On Tue, Nov 06, 2018 at 08:59:13AM +0800, Shiyou Yin wrote:
> Remove invalid operation in the case x and y all equal 0,
> this refine made about 2% speedup for H264 decode on loongson platform.
> ---
>  libavcodec/mips/h264chroma_mmi.c | 970 
> +--
>  1 file changed, 426 insertions(+), 544 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/truemotion2rt: Fix rounding in input size check

2018-11-30 Thread Michael Niedermayer
On Sat, Nov 17, 2018 at 07:23:12PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 11332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2RT_fuzzer-5678456612847616
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/truemotion2rt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] configure: enable mipsfpu for loongson platform.

2018-11-30 Thread Michael Niedermayer
On Thu, Nov 29, 2018 at 05:39:41PM +0800, Shiyou Yin wrote:
> mipsfpu supported by loongson 3a2000,3a3000,3a4000,2k1000, Fate tests passed.
> ---
>  configure | 1 -
>  1 file changed, 1 deletion(-)

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] MPEG DASH Profiles

2018-11-30 Thread Ronak
Hey all,

Is there a reason why ffmpeg only uses the MPEG DASH LIVE profile? Even if I 
want to do VOD, it reports that profile in the manifest files.

I'm thinking of adding support to provide the 4 profiles that MPEG DASH 
supports, and use the same optimization we used to improve the fMP4 generation 
for HLS.

Here is the bug that I'm referring to: https://trac.ffmpeg.org/ticket/7281 


Would the group here be okay with a change like this? For backwards 
compatibility, we could let LIVE be the default profile.

I've noticed that ffmpeg is coded primarily for video and LIVE streaming, and 
other use cases are not as well supported. Why is this the case?

Ronak


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] avformat/movenc : Don't write sidx for empty urls

2018-11-30 Thread Michael Niedermayer
On Fri, Nov 30, 2018 at 05:52:35AM +, Jeyapal, Karthick wrote:
> 
> On 11/29/18 11:08 PM, Michael Niedermayer wrote:
> > On Wed, Nov 28, 2018 at 09:45:24PM +0530, Karthick J wrote:
> >> When movenc is used by other segmenting muxers such as dashenc, url field 
> >> is always empty.
> >> In such cases it is better to not write sidx, instead of throwing errors.
> >> ---
> >>  libavformat/movenc.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >
> > please correct me if i misunderstand but
> > dashenc enables global sidx, skiping writing the sidx then always seems a 
> > bit
> > odd
> Your understanding is correct. 
> But the motive of dashenc is to disable writing of sidx atom for every moof 
> atom (Let's call this as local sidx for the sake of discussion).
> We wanted to disable local sidx as it was adding significant bitrate overhead 
> for chunked streaming(where each frame is a moof).
> To disable local sidx we enabled global sidx. And global sidx was not writing 
> any sidx at all from dashenc due to lack of url. 
> This behavior of not writing any sidx at all is also acceptable for dash. But 
> we just wanted to remove the error, and hence this patch.
> Maybe one could add a new option no_sidx in movenc for this functionality. 
> But since global_sidx was already achieving the same functionality new option 
> seemed a bit redundant.

I have no real oppinion on how to solve it, adding a more specific option
could be done.
but enabling global_sidx and then not doing it silently seems quite hackish
as the intended behavior.
I mean please implement this cleanly, whichever way makes most sense.

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: assert uninitialized pict_type

2018-11-30 Thread Nicolas George
James Almer (2018-11-30):
> probably Clang.

I could have guessed.

Clang: "bogus warnings, gotta catch them all".

The solution is not to make the code less convenient but to fix the
compiler. Or ignore it.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: assert uninitialized pict_type

2018-11-30 Thread James Almer
On 11/30/2018 12:54 PM, Nicolas George wrote:
> James Almer (2018-11-30):
>> And using string literals in an assert may generate warnings.
> 
> [citation needed]
> 
> Anyway, these warnings would be broken, the code is valid.

https://code.videolan.org/videolan/dav1d/issues/196

-Wstring-conversion, probably Clang.

> 
> Regards,
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: assert uninitialized pict_type

2018-11-30 Thread Nicolas George
James Almer (2018-11-30):
> And using string literals in an assert may generate warnings.

[citation needed]

Anyway, these warnings would be broken, the code is valid.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavc/mpeg12dec: Read Closed Captions from second field

2018-11-30 Thread Carl Eugen Hoyos
2018-11-29 18:59 GMT+01:00, Devin Heitmueller :
> On Thu, Nov 29, 2018 at 12:55 PM Michael Niedermayer
>  wrote:
>
>> > +if (s1->a53_caption) {
>> > +AVFrameSideData *sd;
>> > +av_frame_remove_side_data(s->current_picture_ptr->f,
>> > AV_FRAME_DATA_A53_CC);
>> > +sd = av_frame_new_side_data(
>> > +s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
>> > +s1->a53_caption_size);
>> > +if (sd)
>> > +memcpy(sd->data, s1->a53_caption,
>> > s1->a53_caption_size);
>> > +av_freep(>a53_caption);
>> > +}
>>
>> This is probably ok if only one field has data Attached to it, but if both
>> have then both should be exported. Also the user should have some way to
>> find out which of 2 fields data came from
>
> Yeah, this will cause the captions from the first field to get lost.
> It probably makes sense to look at the H.264 decoder, where this is
> done properly (i.e. creating a side data that contains the captions
> from both fields).

Could you provide a sample for me for testing?

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: assert uninitialized pict_type

2018-11-30 Thread James Almer
On 11/30/2018 12:42 PM, Carl Eugen Hoyos wrote:
> 2018-11-30 10:54 GMT+01:00, Linjie Fu :
>> ffmpeg | branch: master | Linjie Fu  | Wed Nov 28
>> 10:41:55 2018 +0800| [67cdfcf694f840d215be940f82545c45c9be193a] | committer:
>> Zhong Li
>>
>> lavc/qsvenc: assert uninitialized pict_type
>>
>> Assert in function ff_qsv_encode to avoid using uninitialized value:
>>
>> FF_DISABLE_DEPRECATION_WARNINGS
>> avctx->coded_frame->pict_type = pict_type;
>> FF_ENABLE_DEPRECATION_WARNINGS
>>
>> Signed-off-by: Linjie Fu 
>> Signed-off-by: Zhong Li 
>>
>>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67cdfcf694f840d215be940f82545c45c9be193a
>> ---
>>
>>  libavcodec/qsvenc.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
>> index 3946c1d837..7f4592f878 100644
>> --- a/libavcodec/qsvenc.c
>> +++ b/libavcodec/qsvenc.c
>> @@ -1337,6 +1337,8 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext
>> *q,
>>  pict_type = AV_PICTURE_TYPE_P;
>>  else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType &
>> MFX_FRAMETYPE_xB)
>>  pict_type = AV_PICTURE_TYPE_B;
>> +else
>> +av_assert0(!"Uninitialized pict_type!");
> 
> You generally cannot assert on a value coming from an external library.

And using string literals in an assert may generate warnings.

Just error out returning AVERROR_INVALIDDATA.

> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: assert uninitialized pict_type

2018-11-30 Thread Carl Eugen Hoyos
2018-11-30 10:54 GMT+01:00, Linjie Fu :
> ffmpeg | branch: master | Linjie Fu  | Wed Nov 28
> 10:41:55 2018 +0800| [67cdfcf694f840d215be940f82545c45c9be193a] | committer:
> Zhong Li
>
> lavc/qsvenc: assert uninitialized pict_type
>
> Assert in function ff_qsv_encode to avoid using uninitialized value:
>
> FF_DISABLE_DEPRECATION_WARNINGS
> avctx->coded_frame->pict_type = pict_type;
> FF_ENABLE_DEPRECATION_WARNINGS
>
> Signed-off-by: Linjie Fu 
> Signed-off-by: Zhong Li 
>
>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67cdfcf694f840d215be940f82545c45c9be193a
> ---
>
>  libavcodec/qsvenc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 3946c1d837..7f4592f878 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1337,6 +1337,8 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext
> *q,
>  pict_type = AV_PICTURE_TYPE_P;
>  else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType &
> MFX_FRAMETYPE_xB)
>  pict_type = AV_PICTURE_TYPE_B;
> +else
> +av_assert0(!"Uninitialized pict_type!");

You generally cannot assert on a value coming from an external library.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] swscale/ppc: Move VSX-using code to its own file

2018-11-30 Thread Lauri Kasanen
On Fri, 30 Nov 2018 12:30:58 +0300
Michael Kostylev  wrote:

> 
> >> Passes fate on LE (with "lavc/jrevdct: Avoid an aliasing violation" 
> >> applied). Can anyone test BE?
> >
> > Ping.
> 
> FATE becomes green as much as possible, I haven't performed any benchmarking 
> though.

Thanks for testing. This patch is not expected to change performance,
it's just moving functions around and putting them under proper VSX
guards.

- Lauri

PS: Your mail did not make it to the list, was it meant for me only?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/mpegenc: extend muxing PCM-DVD to other depths

2018-11-30 Thread Paul B Mahol
On 11/29/18, Paul B Mahol  wrote:
> On 11/29/18, Gyan Doshi  wrote:
>> On 29-11-2018 05:09 PM, Paul B Mahol wrote:
>>> Fixes #6783.
>>>
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>   libavformat/mpegenc.c | 27 +--
>>>   1 file changed, 21 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
>>> index 4c6fa67fb8..1389288b7f 100644
>>> --- a/libavformat/mpegenc.c
>>> +++ b/libavformat/mpegenc.c
>>
>>> +
>>> +switch (st->codecpar->sample_rate) {
>>> +case 48000: freq = 0; break;
>>> +case 96000: freq = 1; break;
>>> +case 44100: freq = 2; break;
>>> +case 32000: freq = 3; break;
>>> +default:
>>> +av_log(ctx, AV_LOG_ERROR, "Unsupported sample
>>> rate.\n");
>>> +return AVERROR(EINVAL);
>>> +}
>> It will be helpful to the users to mention the supported rates.
>
> Already mentioned in encoder.
>

Will apply soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] lavf/dashenc: Use avpriv_io_delete to delete files.

2018-11-30 Thread Andrey Semashev
This fixes incorrect handling of file pseudo-URIs (i.e. when the filename
starts with "file:").
---
 libavformat/dashenc.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..412d7c8a21 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1326,8 +1326,13 @@ static void dashenc_delete_file(AVFormatContext *s, char 
*filename) {
 
 av_dict_free(_opts);
 ff_format_io_close(s, );
-} else if (unlink(filename) < 0) {
-av_log(s, AV_LOG_ERROR, "failed to delete %s: %s\n", filename, 
strerror(errno));
+} else {
+int res = avpriv_io_delete(filename);
+if (res < 0) {
+char errbuf[AV_ERROR_MAX_STRING_SIZE];
+av_strerror(res, errbuf, sizeof(errbuf));
+av_log(s, (res == AVERROR(ENOENT) ? AV_LOG_WARNING : 
AV_LOG_ERROR), "failed to delete %s: %s\n", filename, errbuf);
+}
 }
 }
 
-- 
2.19.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/dashdec: add subtitle stream support

2018-11-30 Thread Liu Steven


> 在 2018年11月15日,下午8:18,Steven Liu  写道:
> 
> Signed-off-by: Steven Liu 
> ---
> libavformat/dashdec.c | 97 +++
> 1 file changed, 90 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 497e7e469c..092947dca2 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -140,6 +140,8 @@ typedef struct DASHContext {
> struct representation **videos;
> int n_audios;
> struct representation **audios;
> +int n_subtitles;
> +struct representation **subtitles;
> 
> /* MediaPresentationDescription Attribute */
> uint64_t media_presentation_duration;
> @@ -393,6 +395,17 @@ static void free_audio_list(DASHContext *c)
> av_freep(>audios);
> c->n_audios = 0;
> }
> +static void free_subtitle_list(DASHContext *c)
> +{
> +int i;
> +for (i = 0; i < c->n_subtitles; i++) {
> +struct representation *pls = c->subtitles[i];
> +free_representation(pls);
> +}
> +av_freep(>subtitles);
> +c->n_subtitles = 0;
> +}
> +
> 
> static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
> AVDictionary *opts, AVDictionary *opts2, int *is_http)
> @@ -565,6 +578,8 @@ static enum AVMediaType get_content_type(xmlNodePtr node)
> type = AVMEDIA_TYPE_VIDEO;
> } else if (av_stristr((const char *)val, "audio")) {
> type = AVMEDIA_TYPE_AUDIO;
> +} else if (av_stristr((const char *)val, "text")) {
> +type = AVMEDIA_TYPE_SUBTITLE;
> }
> xmlFree(val);
> }
> @@ -818,6 +833,7 @@ static int parse_manifest_representation(AVFormatContext 
> *s, const char *url,
>  xmlNodePtr 
> adaptionset_supplementalproperty_node)
> {
> int32_t ret = 0;
> +int32_t subtitle_rep_idx = 0;
> int32_t audio_rep_idx = 0;
> int32_t video_rep_idx = 0;
> DASHContext *c = s->priv_data;
> @@ -854,7 +870,7 @@ static int parse_manifest_representation(AVFormatContext 
> *s, const char *url,
> type = get_content_type(adaptionset_node);
> if (type == AVMEDIA_TYPE_UNKNOWN) {
> av_log(s, AV_LOG_VERBOSE, "Parsing '%s' - skipp not supported 
> representation type\n", url);
> -} else if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) {
> +} else if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || 
> type == AVMEDIA_TYPE_SUBTITLE) {
> // convert selected representation to our internal struct
> rep = av_mallocz(sizeof(struct representation));
> if (!rep) {
> @@ -1048,18 +1064,29 @@ static int 
> parse_manifest_representation(AVFormatContext *s, const char *url,
> av_log(s, AV_LOG_VERBOSE, "Ignoring invalid frame rate 
> '%s'\n", rep_framerate_val);
> }
> 
> -if (type == AVMEDIA_TYPE_VIDEO) {
> -rep->rep_idx = video_rep_idx;
> -dynarray_add(>videos, >n_videos, rep);
> -} else {
> -rep->rep_idx = audio_rep_idx;
> -dynarray_add(>audios, >n_audios, rep);
> +switch (type) {
> +case AVMEDIA_TYPE_VIDEO:
> +rep->rep_idx = video_rep_idx;
> +dynarray_add(>videos, >n_videos, rep);
> +break;
> +case AVMEDIA_TYPE_AUDIO:
> +rep->rep_idx = audio_rep_idx;
> +dynarray_add(>audios, >n_audios, rep);
> +break;
> +case AVMEDIA_TYPE_SUBTITLE:
> +rep->rep_idx = subtitle_rep_idx;
> +dynarray_add(>subtitles, >n_subtitles, rep);
> +break;
> +default:
> +av_log(s, AV_LOG_WARNING, "Unsupported the stream type 
> %d\n", type);
> +break;
> }
> }
> }
> 
> video_rep_idx += type == AVMEDIA_TYPE_VIDEO;
> audio_rep_idx += type == AVMEDIA_TYPE_AUDIO;
> +subtitle_rep_idx += type == AVMEDIA_TYPE_SUBTITLE;
> 
> end:
> if (rep_id_val)
> @@ -1441,6 +1468,8 @@ static int refresh_manifest(AVFormatContext *s)
> struct representation **videos = c->videos;
> int n_audios = c->n_audios;
> struct representation **audios = c->audios;
> +int n_subtitles = c->n_subtitles;
> +struct representation **subtitles = c->subtitles;
> char *base_url = c->base_url;
> 
> c->base_url = NULL;
> @@ -1448,6 +1477,8 @@ static int refresh_manifest(AVFormatContext *s)
> c->videos = NULL;
> c->n_audios = 0;
> c->audios = NULL;
> +c->n_subtitles = 0;
> +c->subtitles = NULL;
> ret = parse_manifest(s, s->url, NULL);
> if (ret)
> goto finish;
> @@ -1464,6 +1495,12 @@ static int refresh_manifest(AVFormatContext *s)
>n_audios, c->n_audios);
> return