Re: [FFmpeg-devel] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-21 Thread Jeyapal, Karthick

On 7/19/19 1:13 PM, leozhang wrote:
> Signed-off-by: leozhang 
> ---
> Removed remarks which are not part of commit message. Thanks reminder
>
>  doc/muxers.texi   |  4 
>  libavformat/dashenc.c | 27 +++
>  2 files changed, 27 insertions(+), 4 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b109297..bc38cf6 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -275,6 +275,10 @@ of the adaptation sets and a,b,c,d and e are the indices 
> of the mapped streams.
>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be 
> used as stream identifier instead of IDs.
>  
>  When no assignment is defined, this defaults to an AdaptationSet for each 
> stream.
> +
> +Optional syntax is "id=x,descriptor=descriptor_string,streams=a,b,c 
> id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
> ISO/IEC 23009-1:2014/Amd.2:2015.
> +For example, -adaptation_sets "id=0,descriptor= schemeIdUri=\"urn:mpeg:dash:srd:2014\" value=\"0,0,0,1,1,2,2\"/>,streams=v".
> +Please note that descriptor string should be a self-closing xml tag.
>  @item timeout @var{timeout}
>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>  @item index_correction @var{index_correction}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b25afb4..24f8d4d 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -68,6 +68,7 @@ typedef struct Segment {
>  
>  typedef struct AdaptationSet {
>  char id[10];
> +char *descriptor;
>  enum AVMediaType media_type;
>  AVDictionary *metadata;
>  AVRational min_frame_rate, max_frame_rate;
> @@ -552,8 +553,10 @@ static void dash_free(AVFormatContext *s)
>  int i, j;
>  
>  if (c->as) {
> -for (i = 0; i < c->nb_as; i++)
> +for (i = 0; i < c->nb_as; i++) {
>  av_dict_free(>as[i].metadata);
> +av_freep(>as[i].descriptor);
> +}
>  av_freep(>as);
>  c->nb_as = 0;
>  }
> @@ -748,7 +751,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> AVIOContext *out, int as_ind
>  role = av_dict_get(as->metadata, "role", NULL, 0);
>  if (role)
>  avio_printf(out, "\t\t\t schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> -
> +if (as->descriptor)
> +avio_printf(out, "\t\t\t%s\n", as->descriptor);
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  char bandwidth_str[64] = {'\0'};
> @@ -820,7 +824,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>  const char *p = c->adaptation_sets;
> -enum { new_set, parse_id, parsing_streams } state;
> +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
>  AdaptationSet *as;
>  int i, n, ret;
>  
> @@ -837,6 +841,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  }
>  
>  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> +// descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015
> +// descriptor_str should be a self-closing xml tag.
>  state = new_set;
>  while (*p) {
>  if (*p == ' ') {
> @@ -854,7 +861,19 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  if (*p)
>  p++;
>  state = parse_id;
> -} else if (state == parse_id && av_strstart(p, "streams=", )) {
> +} else if (state == parse_id && av_strstart(p, "descriptor=", )) {
> +n = strcspn(p, ">") + 1; //followed by one comma, so plus 1
> +if (n < strlen(p)) {
> +as->descriptor = av_strndup(p, n);
> +} else {
> +av_log(s, AV_LOG_ERROR, "Parse error, descriptor string 
> should be a self-closing xml tag\n");
> +return AVERROR(EINVAL);
> +}
> +p += n;
> +if (*p)
> +p++;
> +state = parse_descriptor;
> +} else if ((state == parse_id || state == parse_descriptor) && 
> av_strstart(p, "streams=", )) { //descriptor is optional 
>  state = parsing_streams;
>  } else if (state == parsing_streams) {
>  AdaptationSet *as = >as[c->nb_as - 1];

Pushed, with minor change to commit message and removing a trailing space.

Regards,
Karthick

___
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] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-19 Thread Moritz Barsnick
On Fri, Jul 19, 2019 at 11:08:00 +0800, leozhang wrote:
> change history:
> 1. Use normal descriptor string instead of base64 encoded
> 2. Add example to muxers.texi
> 3. Change descriptor char * and allocate it dynamically
>
> Please review, thanks

Please take care, the above text has become part of the commit message
but shouldn't be, so it shouldn't be pushed that way either.

You need to add remarks to your emails below the '---' line:
>
> Signed-off-by: leozhang 
> ---

Right here.

>  doc/muxers.texi   |  4 
>  libavformat/dashenc.c | 27 +++
>  2 files changed, 27 insertions(+), 4 deletions(-)

Cheers,
Moritz
___
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] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-18 Thread Jeyapal, Karthick

On 7/19/19 8:38 AM, leozhang wrote:
> change history:
> 1. Use normal descriptor string instead of base64 encoded
> 2. Add example to muxers.texi
> 3. Change descriptor char * and allocate it dynamically
>
> Please review, thanks
Thanks for sending the revised patch. LGTM.
I will wait for 3 days and then push it, if there are no other objections.

Regards,
Karthick
>
> Signed-off-by: leozhang 
> ---
>  doc/muxers.texi   |  4 
>  libavformat/dashenc.c | 27 +++
>  2 files changed, 27 insertions(+), 4 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b109297..bc38cf6 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -275,6 +275,10 @@ of the adaptation sets and a,b,c,d and e are the indices 
> of the mapped streams.
>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be 
> used as stream identifier instead of IDs.
>  
>  When no assignment is defined, this defaults to an AdaptationSet for each 
> stream.
> +
> +Optional syntax is "id=x,descriptor=descriptor_string,streams=a,b,c 
> id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
> ISO/IEC 23009-1:2014/Amd.2:2015.
> +For example, -adaptation_sets "id=0,descriptor= schemeIdUri=\"urn:mpeg:dash:srd:2014\" value=\"0,0,0,1,1,2,2\"/>,streams=v".
> +Please note that descriptor string should be a self-closing xml tag.
>  @item timeout @var{timeout}
>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>  @item index_correction @var{index_correction}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b25afb4..24f8d4d 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -68,6 +68,7 @@ typedef struct Segment {
>  
>  typedef struct AdaptationSet {
>  char id[10];
> +char *descriptor;
>  enum AVMediaType media_type;
>  AVDictionary *metadata;
>  AVRational min_frame_rate, max_frame_rate;
> @@ -552,8 +553,10 @@ static void dash_free(AVFormatContext *s)
>  int i, j;
>  
>  if (c->as) {
> -for (i = 0; i < c->nb_as; i++)
> +for (i = 0; i < c->nb_as; i++) {
>  av_dict_free(>as[i].metadata);
> +av_freep(>as[i].descriptor);
> +}
>  av_freep(>as);
>  c->nb_as = 0;
>  }
> @@ -748,7 +751,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> AVIOContext *out, int as_ind
>  role = av_dict_get(as->metadata, "role", NULL, 0);
>  if (role)
>  avio_printf(out, "\t\t\t schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> -
> +if (as->descriptor)
> +avio_printf(out, "\t\t\t%s\n", as->descriptor);
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  char bandwidth_str[64] = {'\0'};
> @@ -820,7 +824,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>  const char *p = c->adaptation_sets;
> -enum { new_set, parse_id, parsing_streams } state;
> +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
>  AdaptationSet *as;
>  int i, n, ret;
>  
> @@ -837,6 +841,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  }
>  
>  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> +// descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015
> +// descriptor_str should be a self-closing xml tag.
>  state = new_set;
>  while (*p) {
>  if (*p == ' ') {
> @@ -854,7 +861,19 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  if (*p)
>  p++;
>  state = parse_id;
> -} else if (state == parse_id && av_strstart(p, "streams=", )) {
> +} else if (state == parse_id && av_strstart(p, "descriptor=", )) {
> +n = strcspn(p, ">") + 1; //followed by one comma, so plus 1
> +if (n < strlen(p)) {
> +as->descriptor = av_strndup(p, n);
> +} else {
> +av_log(s, AV_LOG_ERROR, "Parse error, descriptor string 
> should be a self-closing xml tag\n");
> +return AVERROR(EINVAL);
> +}
> +p += n;
> +if (*p)
> +p++;
> +state = parse_descriptor;
> +} else if ((state == parse_id || state == parse_descriptor) && 
> av_strstart(p, "streams=", )) { //descriptor is optional 
>  state = parsing_streams;
>  } else if (state == parsing_streams) {
>  AdaptationSet *as = >as[c->nb_as - 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] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-17 Thread Jeyapal, Karthick

On 7/17/19 10:21 AM, Tao Zhang wrote:
> Jeyapal, Karthick  于2019年7月17日周三 上午10:46写道:
>>
>>
>> On 7/15/19 8:41 AM, leozhang wrote:
>>> change history:
>>> 1. remove unnecessary cast.
>>> 2. add some braces.
>>>
>>> Please comment, Thanks
>> Thanks for sending the patch. Please find some of my comments inlined below.
> Thanks for your comments. I made some changes below. Please review it, thanks.
>>>
>>> Signed-off-by: leozhang 
>>> ---
>>>  doc/muxers.texi   |  3 +++
>>>  libavformat/dashenc.c | 35 ---
>>>  2 files changed, 35 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>>> index b109297..ac06ad2 100644
>>> --- a/doc/muxers.texi
>>> +++ b/doc/muxers.texi
>>> @@ -275,6 +275,9 @@ of the adaptation sets and a,b,c,d and e are the 
>>> indices of the mapped streams.
>>>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can 
>>> be used as stream identifier instead of IDs.
>>>
>>>  When no assignment is defined, this defaults to an AdaptationSet for each 
>>> stream.
>>> +
>>> +Optional syntax is "id=x,descriptor=descriptor_str,streams=a,b,c 
>>> id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
>>> ISO/IEC 23009-1:2014/Amd.2:2015.
>>> +And descriptor_str must be a properly formatted XML element, which is 
>>> encoded by base64.
>> Two comments:
>> 1. Please provide an example here. So that it is easier for people to 
>> understand
> For the instance using descriptor in VR tiled video application,
> this short interesting video
> https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/multimedia-communications/research-topics/mpeg-omaf.html
> is more intuitive than a textual description.
> Then, how DASH pack media data in tile based streaming?
> Refer ISO/IEC 23009-1:2014/Amd.2:2015, for example, the descriptor
> string  value="0,0,0,1,1,2,2"/> indicates that AdaptationSet is
> the top-left corner tile of full video divided into 2x2 tiles.
> Finally, how to use FFmpeg DASH muxer to generate the tile based streaming?
> We split the video by NxN tiles, insert descriptor syntax together
> with AdaptationSet in MPD.
> For example, the pseudo ffmpeg command {-adaptation_sets
> "id=0,descriptor=PFN1cHBsZW1lbnRhbFByb3BlcnR5IHNjaGVtZUlkVXJpPSJ1cm46bXBlZzpkYXNoOnNyZDoyMDE0IiB2YWx1ZT0iMCwwLDAsMSwxLDIsMiIvPg==,streams=v"}
> will
> insert descriptor string  schemeIdUri="urn:mpeg:dash:srd:2014" value="0,0,0,1,1,2,2"/> like
> below
> 
>  subsegmentStartsWithSAP="1">
>  value="0,0,0,1,1,2,2"/>
>  width="640" height="360" bandwidth="218284" startWithSAP="1">
>   ...
> 
> 
>
> In addition to VR applications, zoomed video part can also be
> indicated by descriptor.
Thanks for the detailed explanation. Please add the following/similar line to 
muxers.texi
For example, 
-adaptation_sets "id=0,descriptor=,streams=v"
>> 2. Why do we need this to be base64 encoded? What is the use-case where a 
>> normal string doesn't work?
> The parser code used comma and space as separator. The unencrypted
> descriptor string like  schemeIdUri="urn:mpeg:dash:srd:2014" value="0,0,0,1,1,2,2"/> contains
> comma and space, which disturbs the normal parse result.
Space is used as separator, only outside the if..else.. conditions. So, it 
won't count for spaces inside the descriptor string.
Regarding comma separator you can change the logic for descriptor alone, as the 
relevant code is anyways inside an "else if" for descriptor. 
You can look for ''>" symbol as the terminating char, instead of looking for a 
separator. Also add a note in muxers.texi mentioning that descriptor string 
should be a self-closing xml tag.
It is easier for users to send a self-closing xml tag as a command line input, 
rather than a base64 encoded string.
>>>  @item timeout @var{timeout}
>>>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>>>  @item index_correction @var{index_correction}
>>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>>> index b25afb4..a48031c 100644
>>> --- a/libavformat/dashenc.c
>>> +++ b/libavformat/dashenc.c
>>> @@ -34,6 +34,7 @@
>>>  #include "libavutil/rational.h"
>>>  #include "libavutil/time.h"
>>>  #include "libavutil/time_internal.h"
>>> +#include "libavutil/base64.h"
>>>
>>>  #include "avc.h"
>>>  #include "avformat.h"
>>> @@ -68,6 +69,7 @@ typedef struct Segment {
>>>
>>>  typedef struct AdaptationSet {
>>>  char id[10];
>>> +char descriptor[1024];
>> Please change this char * and allocate it dynamically. I understand there 
>> are some legacy code in dashenc using this 1024 length.
>> But at least new code should follow dynamic allocation.
> Agree, will fix it
>>>  enum AVMediaType media_type;
>>>  AVDictionary *metadata;
>>>  AVRational min_frame_rate, max_frame_rate;
>>> @@ -748,7 +750,8 @@ static int write_adaptation_set(AVFormatContext *s, 
>>> AVIOContext *out, int as_ind
>>>  role = av_dict_get(as->metadata, "role", NULL, 0);

Re: [FFmpeg-devel] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-16 Thread Tao Zhang
Jeyapal, Karthick  于2019年7月17日周三 上午10:46写道:
>
>
> On 7/15/19 8:41 AM, leozhang wrote:
> > change history:
> > 1. remove unnecessary cast.
> > 2. add some braces.
> >
> > Please comment, Thanks
> Thanks for sending the patch. Please find some of my comments inlined below.
Thanks for your comments. I made some changes below. Please review it, thanks.
> >
> > Signed-off-by: leozhang 
> > ---
> >  doc/muxers.texi   |  3 +++
> >  libavformat/dashenc.c | 35 ---
> >  2 files changed, 35 insertions(+), 3 deletions(-)
> >
> > diff --git a/doc/muxers.texi b/doc/muxers.texi
> > index b109297..ac06ad2 100644
> > --- a/doc/muxers.texi
> > +++ b/doc/muxers.texi
> > @@ -275,6 +275,9 @@ of the adaptation sets and a,b,c,d and e are the 
> > indices of the mapped streams.
> >  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can 
> > be used as stream identifier instead of IDs.
> >
> >  When no assignment is defined, this defaults to an AdaptationSet for each 
> > stream.
> > +
> > +Optional syntax is "id=x,descriptor=descriptor_str,streams=a,b,c 
> > id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
> > ISO/IEC 23009-1:2014/Amd.2:2015.
> > +And descriptor_str must be a properly formatted XML element, which is 
> > encoded by base64.
> Two comments:
> 1. Please provide an example here. So that it is easier for people to 
> understand
For the instance using descriptor in VR tiled video application,
this short interesting video
https://www.hhi.fraunhofer.de/en/departments/vca/research-groups/multimedia-communications/research-topics/mpeg-omaf.html
is more intuitive than a textual description.
Then, how DASH pack media data in tile based streaming?
Refer ISO/IEC 23009-1:2014/Amd.2:2015, for example, the descriptor
string  indicates that AdaptationSet is
the top-left corner tile of full video divided into 2x2 tiles.
Finally, how to use FFmpeg DASH muxer to generate the tile based streaming?
We split the video by NxN tiles, insert descriptor syntax together
with AdaptationSet in MPD.
For example, the pseudo ffmpeg command {-adaptation_sets
"id=0,descriptor=PFN1cHBsZW1lbnRhbFByb3BlcnR5IHNjaGVtZUlkVXJpPSJ1cm46bXBlZzpkYXNoOnNyZDoyMDE0IiB2YWx1ZT0iMCwwLDAsMSwxLDIsMiIvPg==,streams=v"}
will
insert descriptor string  like
below




  ...



In addition to VR applications, zoomed video part can also be
indicated by descriptor.
> 2. Why do we need this to be base64 encoded? What is the use-case where a 
> normal string doesn't work?
The parser code used comma and space as separator. The unencrypted
descriptor string like  contains
comma and space, which disturbs the normal parse result.
> >  @item timeout @var{timeout}
> >  Set timeout for socket I/O operations. Applicable only for HTTP output.
> >  @item index_correction @var{index_correction}
> > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> > index b25afb4..a48031c 100644
> > --- a/libavformat/dashenc.c
> > +++ b/libavformat/dashenc.c
> > @@ -34,6 +34,7 @@
> >  #include "libavutil/rational.h"
> >  #include "libavutil/time.h"
> >  #include "libavutil/time_internal.h"
> > +#include "libavutil/base64.h"
> >
> >  #include "avc.h"
> >  #include "avformat.h"
> > @@ -68,6 +69,7 @@ typedef struct Segment {
> >
> >  typedef struct AdaptationSet {
> >  char id[10];
> > +char descriptor[1024];
> Please change this char * and allocate it dynamically. I understand there are 
> some legacy code in dashenc using this 1024 length.
> But at least new code should follow dynamic allocation.
Agree, will fix it
> >  enum AVMediaType media_type;
> >  AVDictionary *metadata;
> >  AVRational min_frame_rate, max_frame_rate;
> > @@ -748,7 +750,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> > AVIOContext *out, int as_ind
> >  role = av_dict_get(as->metadata, "role", NULL, 0);
> >  if (role)
> >  avio_printf(out, "\t\t\t > schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> > -
> > +if (strlen(as->descriptor))
> > +avio_printf(out, "\t\t\t%s\n", as->descriptor);
> >  for (i = 0; i < s->nb_streams; i++) {
> >  OutputStream *os = >streams[i];
> >  char bandwidth_str[64] = {'\0'};
> > @@ -820,7 +823,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
> >  {
> >  DASHContext *c = s->priv_data;
> >  const char *p = c->adaptation_sets;
> > -enum { new_set, parse_id, parsing_streams } state;
> > +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
> >  AdaptationSet *as;
> >  int i, n, ret;
> >
> > @@ -837,6 +840,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
> >  }
> >
> >  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> > +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> > +// descriptor is useful to the scheme defined by ISO/IEC 
> > 23009-1:2014/Amd.2:2015
> > +// descriptor_str must be a properly 

Re: [FFmpeg-devel] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-16 Thread Jeyapal, Karthick

On 7/15/19 8:41 AM, leozhang wrote:
> change history:
> 1. remove unnecessary cast.
> 2. add some braces.
>
> Please comment, Thanks
Thanks for sending the patch. Please find some of my comments inlined below.
>
> Signed-off-by: leozhang 
> ---
>  doc/muxers.texi   |  3 +++
>  libavformat/dashenc.c | 35 ---
>  2 files changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b109297..ac06ad2 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -275,6 +275,9 @@ of the adaptation sets and a,b,c,d and e are the indices 
> of the mapped streams.
>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be 
> used as stream identifier instead of IDs.
>  
>  When no assignment is defined, this defaults to an AdaptationSet for each 
> stream.
> +
> +Optional syntax is "id=x,descriptor=descriptor_str,streams=a,b,c 
> id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
> ISO/IEC 23009-1:2014/Amd.2:2015.
> +And descriptor_str must be a properly formatted XML element, which is 
> encoded by base64.
Two comments:
1. Please provide an example here. So that it is easier for people to understand
2. Why do we need this to be base64 encoded? What is the use-case where a 
normal string doesn't work?
>  @item timeout @var{timeout}
>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>  @item index_correction @var{index_correction}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b25afb4..a48031c 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/rational.h"
>  #include "libavutil/time.h"
>  #include "libavutil/time_internal.h"
> +#include "libavutil/base64.h"
>  
>  #include "avc.h"
>  #include "avformat.h"
> @@ -68,6 +69,7 @@ typedef struct Segment {
>  
>  typedef struct AdaptationSet {
>  char id[10];
> +char descriptor[1024];
Please change this char * and allocate it dynamically. I understand there are 
some legacy code in dashenc using this 1024 length.
But at least new code should follow dynamic allocation.
>  enum AVMediaType media_type;
>  AVDictionary *metadata;
>  AVRational min_frame_rate, max_frame_rate;
> @@ -748,7 +750,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> AVIOContext *out, int as_ind
>  role = av_dict_get(as->metadata, "role", NULL, 0);
>  if (role)
>  avio_printf(out, "\t\t\t schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> -
> +if (strlen(as->descriptor))
> +avio_printf(out, "\t\t\t%s\n", as->descriptor);
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  char bandwidth_str[64] = {'\0'};
> @@ -820,7 +823,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>  const char *p = c->adaptation_sets;
> -enum { new_set, parse_id, parsing_streams } state;
> +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
>  AdaptationSet *as;
>  int i, n, ret;
>  
> @@ -837,6 +840,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  }
>  
>  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> +// descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015
> +// descriptor_str must be a properly formatted XML element, encoded by 
> base64.
>  state = new_set;
>  while (*p) {
>  if (*p == ' ') {
> @@ -854,7 +860,30 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  if (*p)
>  p++;
>  state = parse_id;
> -} else if (state == parse_id && av_strstart(p, "streams=", )) {
> +} else if (state == parse_id && av_strstart(p, "descriptor=", )) {
> +char *encode_str, *decode_str;
> +int decode_size, ret;
> +
> +n = strcspn(p, ",");
> +encode_str = av_strndup(p, n);
> +decode_size = AV_BASE64_DECODE_SIZE(n);
> +decode_str = av_mallocz(decode_size);
> +if (decode_str) {
> +ret = av_base64_decode(decode_str, encode_str, decode_size);
> +if (ret >= 0)
> +snprintf(as->descriptor, sizeof(as->descriptor), "%.*s", 
> decode_size, decode_str);
> +else
> +av_log(s, AV_LOG_WARNING, "descriptor string is invalid 
> base64 encode\n");
> +} else {
> +av_log(s, AV_LOG_WARNING, "av_mallocz failed, will not parse 
> descriptor\n");
> +}
> +p += n;
> +if (*p)
> +p++;
> +state = parse_descriptor;
> +av_freep(_str);
> +av_freep(_str);
> +} else if ((state == parse_id || state == parse_descriptor) && 
> av_strstart(p, 

Re: [FFmpeg-devel] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-16 Thread Tao Zhang
Let me add that, descriptor provides extensible syntax and semantics
for describing Adaptation Set properties.
In my scenario,I implemented one VR tiled video system using descriptor.

leozhang  于2019年7月15日周一 上午11:11写道:
>
> change history:
> 1. remove unnecessary cast.
> 2. add some braces.
>
> Please comment, Thanks
>
> Signed-off-by: leozhang 
> ---
>  doc/muxers.texi   |  3 +++
>  libavformat/dashenc.c | 35 ---
>  2 files changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b109297..ac06ad2 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -275,6 +275,9 @@ of the adaptation sets and a,b,c,d and e are the indices 
> of the mapped streams.
>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be 
> used as stream identifier instead of IDs.
>
>  When no assignment is defined, this defaults to an AdaptationSet for each 
> stream.
> +
> +Optional syntax is "id=x,descriptor=descriptor_str,streams=a,b,c 
> id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
> ISO/IEC 23009-1:2014/Amd.2:2015.
> +And descriptor_str must be a properly formatted XML element, which is 
> encoded by base64.
>  @item timeout @var{timeout}
>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>  @item index_correction @var{index_correction}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b25afb4..a48031c 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/rational.h"
>  #include "libavutil/time.h"
>  #include "libavutil/time_internal.h"
> +#include "libavutil/base64.h"
>
>  #include "avc.h"
>  #include "avformat.h"
> @@ -68,6 +69,7 @@ typedef struct Segment {
>
>  typedef struct AdaptationSet {
>  char id[10];
> +char descriptor[1024];
>  enum AVMediaType media_type;
>  AVDictionary *metadata;
>  AVRational min_frame_rate, max_frame_rate;
> @@ -748,7 +750,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> AVIOContext *out, int as_ind
>  role = av_dict_get(as->metadata, "role", NULL, 0);
>  if (role)
>  avio_printf(out, "\t\t\t schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> -
> +if (strlen(as->descriptor))
> +avio_printf(out, "\t\t\t%s\n", as->descriptor);
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  char bandwidth_str[64] = {'\0'};
> @@ -820,7 +823,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>  const char *p = c->adaptation_sets;
> -enum { new_set, parse_id, parsing_streams } state;
> +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
>  AdaptationSet *as;
>  int i, n, ret;
>
> @@ -837,6 +840,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  }
>
>  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> +// descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015
> +// descriptor_str must be a properly formatted XML element, encoded by 
> base64.
>  state = new_set;
>  while (*p) {
>  if (*p == ' ') {
> @@ -854,7 +860,30 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  if (*p)
>  p++;
>  state = parse_id;
> -} else if (state == parse_id && av_strstart(p, "streams=", )) {
> +} else if (state == parse_id && av_strstart(p, "descriptor=", )) {
> +char *encode_str, *decode_str;
> +int decode_size, ret;
> +
> +n = strcspn(p, ",");
> +encode_str = av_strndup(p, n);
> +decode_size = AV_BASE64_DECODE_SIZE(n);
> +decode_str = av_mallocz(decode_size);
> +if (decode_str) {
> +ret = av_base64_decode(decode_str, encode_str, decode_size);
> +if (ret >= 0)
> +snprintf(as->descriptor, sizeof(as->descriptor), "%.*s", 
> decode_size, decode_str);
> +else
> +av_log(s, AV_LOG_WARNING, "descriptor string is invalid 
> base64 encode\n");
> +} else {
> +av_log(s, AV_LOG_WARNING, "av_mallocz failed, will not parse 
> descriptor\n");
> +}
> +p += n;
> +if (*p)
> +p++;
> +state = parse_descriptor;
> +av_freep(_str);
> +av_freep(_str);
> +} else if ((state == parse_id || state == parse_descriptor) && 
> av_strstart(p, "streams=", )) { //descriptor is optional
>  state = parsing_streams;
>  } else if (state == parsing_streams) {
>  AdaptationSet *as = >as[c->nb_as - 1];
> --
> 1.8.3.1
>
> ___
> ffmpeg-devel mailing list
> 

Re: [FFmpeg-devel] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-14 Thread Carl Eugen Hoyos
Am Fr., 12. Juli 2019 um 10:31 Uhr schrieb leozhang :
>
>  Reference ISO/IEC 23009-1:2014/Amd.2:2015, a spatial relationship descriptor 
> is defined as a spatial part of a content component (e.g. a region of 
> interest, or a tile)
>  and represented by either an Adaptation Set or a Sub-Representation.
>
> Signed-off-by: leozhang 
> ---
>  doc/muxers.texi   |  3 +++
>  libavformat/dashenc.c | 36 +---
>  2 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b109297..ac06ad2 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -275,6 +275,9 @@ of the adaptation sets and a,b,c,d and e are the indices 
> of the mapped streams.
>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be 
> used as stream identifier instead of IDs.
>
>  When no assignment is defined, this defaults to an AdaptationSet for each 
> stream.

> +Optional syntax is "id=x,descriptor=descriptor_str,streams=a,b,c 
> id=y,streams=d,e" and so
> on, descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015.
> +And descriptor_str must be a properly formatted XML element, which is 
> encoded by base64.

I wonder how helpful these two sentences are, perhaps somebody who uses
dash can comment?

>  @item timeout @var{timeout}
>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>  @item index_correction @var{index_correction}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b25afb4..f7ebb1f 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/rational.h"
>  #include "libavutil/time.h"
>  #include "libavutil/time_internal.h"
> +#include "libavutil/base64.h"
>
>  #include "avc.h"
>  #include "avformat.h"
> @@ -68,6 +69,7 @@ typedef struct Segment {
>
>  typedef struct AdaptationSet {
>  char id[10];
> +char descriptor[1024];
>  enum AVMediaType media_type;
>  AVDictionary *metadata;
>  AVRational min_frame_rate, max_frame_rate;
> @@ -748,7 +750,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> AVIOContext *out, int as_ind
>  role = av_dict_get(as->metadata, "role", NULL, 0);
>  if (role)
>  avio_printf(out, "\t\t\t schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> -
> +if (strlen(as->descriptor))
> +avio_printf(out, "\t\t\t%s\n", as->descriptor);
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  char bandwidth_str[64] = {'\0'};
> @@ -820,7 +823,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>  const char *p = c->adaptation_sets;
> -enum { new_set, parse_id, parsing_streams } state;
> +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
>  AdaptationSet *as;
>  int i, n, ret;
>
> @@ -837,6 +840,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  }
>
>  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> +// descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015
> +// descriptor_str must be a properly formatted XML element, encoded by 
> base64.
>  state = new_set;
>  while (*p) {
>  if (*p == ' ') {
> @@ -854,7 +860,31 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  if (*p)
>  p++;
>  state = parse_id;
> -} else if (state == parse_id && av_strstart(p, "streams=", )) {
> +} else if (state == parse_id && av_strstart(p, "descriptor=", )) {
> +char *encode_str;
> +uint8_t *decode_str;
> +int decode_size, ret;
> +
> +n = strcspn(p, ",");
> +encode_str = av_strndup(p, n);
> +decode_size = AV_BASE64_DECODE_SIZE(n);

> +decode_str = (uint8_t *)av_mallocz(decode_size);

Why is this (ugly) cast necessary?

> +if (decode_str) {
> +ret = av_base64_decode(decode_str, encode_str, decode_size);
> +if (ret >= 0)
> +snprintf(as->descriptor, sizeof(as->descriptor), "%.*s", 
> decode_size, decode_str);
> +else
> +av_log(s, AV_LOG_WARNING, "descriptor string is invalid 
> base64 encode\n");
> +} else
> +av_log(s, AV_LOG_WARNING, "av_mallocz failed, will not parse 
> descriptor\n");

Please add some braces.

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] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.

2019-07-14 Thread Tao Zhang
ping?

leozhang  于2019年7月12日周五 下午4:31写道:
>
>  Reference ISO/IEC 23009-1:2014/Amd.2:2015, a spatial relationship descriptor 
> is defined as a spatial part of a content component (e.g. a region of 
> interest, or a tile)
>  and represented by either an Adaptation Set or a Sub-Representation.
>
> Signed-off-by: leozhang 
> ---
>  doc/muxers.texi   |  3 +++
>  libavformat/dashenc.c | 36 +---
>  2 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b109297..ac06ad2 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -275,6 +275,9 @@ of the adaptation sets and a,b,c,d and e are the indices 
> of the mapped streams.
>  To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be 
> used as stream identifier instead of IDs.
>
>  When no assignment is defined, this defaults to an AdaptationSet for each 
> stream.
> +
> +Optional syntax is "id=x,descriptor=descriptor_str,streams=a,b,c 
> id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by 
> ISO/IEC 23009-1:2014/Amd.2:2015.
> +And descriptor_str must be a properly formatted XML element, which is 
> encoded by base64.
>  @item timeout @var{timeout}
>  Set timeout for socket I/O operations. Applicable only for HTTP output.
>  @item index_correction @var{index_correction}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index b25afb4..f7ebb1f 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/rational.h"
>  #include "libavutil/time.h"
>  #include "libavutil/time_internal.h"
> +#include "libavutil/base64.h"
>
>  #include "avc.h"
>  #include "avformat.h"
> @@ -68,6 +69,7 @@ typedef struct Segment {
>
>  typedef struct AdaptationSet {
>  char id[10];
> +char descriptor[1024];
>  enum AVMediaType media_type;
>  AVDictionary *metadata;
>  AVRational min_frame_rate, max_frame_rate;
> @@ -748,7 +750,8 @@ static int write_adaptation_set(AVFormatContext *s, 
> AVIOContext *out, int as_ind
>  role = av_dict_get(as->metadata, "role", NULL, 0);
>  if (role)
>  avio_printf(out, "\t\t\t schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
> -
> +if (strlen(as->descriptor))
> +avio_printf(out, "\t\t\t%s\n", as->descriptor);
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  char bandwidth_str[64] = {'\0'};
> @@ -820,7 +823,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>  const char *p = c->adaptation_sets;
> -enum { new_set, parse_id, parsing_streams } state;
> +enum { new_set, parse_id, parsing_streams, parse_descriptor } state;
>  AdaptationSet *as;
>  int i, n, ret;
>
> @@ -837,6 +840,9 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  }
>
>  // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on
> +// option id=0,descriptor=descriptor_str,streams=0,1,2 and so on
> +// descriptor is useful to the scheme defined by ISO/IEC 
> 23009-1:2014/Amd.2:2015
> +// descriptor_str must be a properly formatted XML element, encoded by 
> base64.
>  state = new_set;
>  while (*p) {
>  if (*p == ' ') {
> @@ -854,7 +860,31 @@ static int parse_adaptation_sets(AVFormatContext *s)
>  if (*p)
>  p++;
>  state = parse_id;
> -} else if (state == parse_id && av_strstart(p, "streams=", )) {
> +} else if (state == parse_id && av_strstart(p, "descriptor=", )) {
> +char *encode_str;
> +uint8_t *decode_str;
> +int decode_size, ret;
> +
> +n = strcspn(p, ",");
> +encode_str = av_strndup(p, n);
> +decode_size = AV_BASE64_DECODE_SIZE(n);
> +decode_str = (uint8_t *)av_mallocz(decode_size);
> +if (decode_str) {
> +ret = av_base64_decode(decode_str, encode_str, decode_size);
> +if (ret >= 0)
> +snprintf(as->descriptor, sizeof(as->descriptor), "%.*s", 
> decode_size, decode_str);
> +else
> +av_log(s, AV_LOG_WARNING, "descriptor string is invalid 
> base64 encode\n");
> +} else
> +av_log(s, AV_LOG_WARNING, "av_mallocz failed, will not parse 
> descriptor\n");
> +
> +p += n;
> +if (*p)
> +p++;
> +state = parse_descriptor;
> +av_freep(_str);
> +av_freep(_str);
> +} else if ((state == parse_id || state == parse_descriptor) && 
> av_strstart(p, "streams=", )) { //descriptor is optional
>  state = parsing_streams;
>  } else if (state == parsing_streams) {
>  AdaptationSet *as = >as[c->nb_as - 1];
> --
> 1.8.3.1
>
> ___
> ffmpeg-devel mailing list
>