Message ID | 1591746194-13213-3-git-send-email-lance.lmwang@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [FFmpeg-devel,v10,1/4] avutil: add AV_FRAME_DATA_SEI_UNREGISTERED side data type | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On Wed, 10 Jun 2020, lance.lmwang@gmail.com wrote: > From: Limin Wang <lance.lmwang@gmail.com> > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > --- > libavfilter/vf_showinfo.c | 37 +++++++++++++++++++++++++++++++++++++ Commit subject is wrong. > 1 file changed, 37 insertions(+) > > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c > index 5d4aee4..9eaf8ff 100644 > --- a/libavfilter/vf_showinfo.c > +++ b/libavfilter/vf_showinfo.c > @@ -23,6 +23,7 @@ > */ > > #include <inttypes.h> > +#include <ctype.h> Use av_isgraph() instead, ctype is locale dependant. Regards, Marton > > #include "libavutil/bswap.h" > #include "libavutil/adler32.h" > @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd) > av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks); > } > > +static int string_is_print(const uint8_t *str) > +{ > + while (isprint(*str)) str++; > + return !*str; > +} > + > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd) > +{ > + const int uuid_size = 16; > + uint8_t *user_data = sd->data; > + > + if (sd->size < uuid_size) { > + av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size); > + return; > + } > + > + av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n"); > + av_log(ctx, AV_LOG_INFO, "UUID="); > + for (int i = 0; i < uuid_size; i++) { > + av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]); > + if (i == 3 || i == 5 || i == 7 || i == 9) > + av_log(ctx, AV_LOG_INFO, "-"); > + } > + av_log(ctx, AV_LOG_INFO, "\n"); > + > + user_data += uuid_size; > + /* Only print the user data details if it's string */ > + if (string_is_print(user_data)) { > + av_log(ctx, AV_LOG_INFO, "User Data="); > + av_log(ctx, AV_LOG_INFO, "%s", user_data); > + } > +} > + > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) > { > const char *color_range_str = av_color_range_name(frame->color_range); > @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) > case AV_FRAME_DATA_VIDEO_ENC_PARAMS: > dump_video_enc_params(ctx, sd); > break; > + case AV_FRAME_DATA_SEI_UNREGISTERED: > + dump_sei_unregistered_metadata(ctx, sd); > + break; > default: > av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", > sd->type, sd->size); > -- > 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-request@ffmpeg.org with subject "unsubscribe".
On Wed, Jun 10, 2020 at 10:49:33AM +0200, Marton Balint wrote: > > > On Wed, 10 Jun 2020, lance.lmwang@gmail.com wrote: > > > From: Limin Wang <lance.lmwang@gmail.com> > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > > --- > > libavfilter/vf_showinfo.c | 37 +++++++++++++++++++++++++++++++++++++ > > Commit subject is wrong. will fix it > > > 1 file changed, 37 insertions(+) > > > > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c > > index 5d4aee4..9eaf8ff 100644 > > --- a/libavfilter/vf_showinfo.c > > +++ b/libavfilter/vf_showinfo.c > > @@ -23,6 +23,7 @@ > > */ > > > > #include <inttypes.h> > > +#include <ctype.h> > > Use av_isgraph() instead, ctype is locale dependant. OK, will use it. > > Regards, > Marton > > > > > #include "libavutil/bswap.h" > > #include "libavutil/adler32.h" > > @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd) > > av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks); > > } > > > > +static int string_is_print(const uint8_t *str) > > +{ > > + while (isprint(*str)) str++; > > + return !*str; > > +} > > + > > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd) > > +{ > > + const int uuid_size = 16; > > + uint8_t *user_data = sd->data; > > + > > + if (sd->size < uuid_size) { > > + av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size); > > + return; > > + } > > + > > + av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n"); > > + av_log(ctx, AV_LOG_INFO, "UUID="); > > + for (int i = 0; i < uuid_size; i++) { > > + av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]); > > + if (i == 3 || i == 5 || i == 7 || i == 9) > > + av_log(ctx, AV_LOG_INFO, "-"); > > + } > > + av_log(ctx, AV_LOG_INFO, "\n"); > > + > > + user_data += uuid_size; > > + /* Only print the user data details if it's string */ > > + if (string_is_print(user_data)) { > > + av_log(ctx, AV_LOG_INFO, "User Data="); > > + av_log(ctx, AV_LOG_INFO, "%s", user_data); > > + } > > +} > > + > > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) > > { > > const char *color_range_str = av_color_range_name(frame->color_range); > > @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) > > case AV_FRAME_DATA_VIDEO_ENC_PARAMS: > > dump_video_enc_params(ctx, sd); > > break; > > + case AV_FRAME_DATA_SEI_UNREGISTERED: > > + dump_sei_unregistered_metadata(ctx, sd); > > + break; > > default: > > av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", > > sd->type, sd->size); > > -- > > 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-request@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-request@ffmpeg.org with subject "unsubscribe".
On Wed, Jun 10, 2020 at 10:49:33AM +0200, Marton Balint wrote: > > > On Wed, 10 Jun 2020, lance.lmwang@gmail.com wrote: > > > From: Limin Wang <lance.lmwang@gmail.com> > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > > --- > > libavfilter/vf_showinfo.c | 37 +++++++++++++++++++++++++++++++++++++ > > Commit subject is wrong. > > > 1 file changed, 37 insertions(+) > > > > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c > > index 5d4aee4..9eaf8ff 100644 > > --- a/libavfilter/vf_showinfo.c > > +++ b/libavfilter/vf_showinfo.c > > @@ -23,6 +23,7 @@ > > */ > > > > #include <inttypes.h> > > +#include <ctype.h> > > Use av_isgraph() instead, ctype is locale dependant. It seems that av_isgraph() isn't include all printable ascii, see: https://en.wikipedia.org/wiki/ASCII Codes 20hex to 7Ehex, known as the printable characters, represent letters, digits, punctuation marks, and a few miscellaneous symbols. There are 95 printable characters in total. So I'll not use av_isgraph() and use below code: while (*str && *str >= 0x20 && *str <= 0x7e ) str++; You can test with x264 default SEI user data for check. > > Regards, > Marton > > > > > #include "libavutil/bswap.h" > > #include "libavutil/adler32.h" > > @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd) > > av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks); > > } > > > > +static int string_is_print(const uint8_t *str) > > +{ > > + while (isprint(*str)) str++; > > + return !*str; > > +} > > + > > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd) > > +{ > > + const int uuid_size = 16; > > + uint8_t *user_data = sd->data; > > + > > + if (sd->size < uuid_size) { > > + av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size); > > + return; > > + } > > + > > + av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n"); > > + av_log(ctx, AV_LOG_INFO, "UUID="); > > + for (int i = 0; i < uuid_size; i++) { > > + av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]); > > + if (i == 3 || i == 5 || i == 7 || i == 9) > > + av_log(ctx, AV_LOG_INFO, "-"); > > + } > > + av_log(ctx, AV_LOG_INFO, "\n"); > > + > > + user_data += uuid_size; > > + /* Only print the user data details if it's string */ > > + if (string_is_print(user_data)) { > > + av_log(ctx, AV_LOG_INFO, "User Data="); > > + av_log(ctx, AV_LOG_INFO, "%s", user_data); > > + } > > +} > > + > > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) > > { > > const char *color_range_str = av_color_range_name(frame->color_range); > > @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) > > case AV_FRAME_DATA_VIDEO_ENC_PARAMS: > > dump_video_enc_params(ctx, sd); > > break; > > + case AV_FRAME_DATA_SEI_UNREGISTERED: > > + dump_sei_unregistered_metadata(ctx, sd); > > + break; > > default: > > av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", > > sd->type, sd->size); > > -- > > 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-request@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-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 5d4aee4..9eaf8ff 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -23,6 +23,7 @@ */ #include <inttypes.h> +#include <ctype.h> #include "libavutil/bswap.h" #include "libavutil/adler32.h" @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd) av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks); } +static int string_is_print(const uint8_t *str) +{ + while (isprint(*str)) str++; + return !*str; +} + +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd) +{ + const int uuid_size = 16; + uint8_t *user_data = sd->data; + + if (sd->size < uuid_size) { + av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size); + return; + } + + av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n"); + av_log(ctx, AV_LOG_INFO, "UUID="); + for (int i = 0; i < uuid_size; i++) { + av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]); + if (i == 3 || i == 5 || i == 7 || i == 9) + av_log(ctx, AV_LOG_INFO, "-"); + } + av_log(ctx, AV_LOG_INFO, "\n"); + + user_data += uuid_size; + /* Only print the user data details if it's string */ + if (string_is_print(user_data)) { + av_log(ctx, AV_LOG_INFO, "User Data="); + av_log(ctx, AV_LOG_INFO, "%s", user_data); + } +} + static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) { const char *color_range_str = av_color_range_name(frame->color_range); @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) case AV_FRAME_DATA_VIDEO_ENC_PARAMS: dump_video_enc_params(ctx, sd); break; + case AV_FRAME_DATA_SEI_UNREGISTERED: + dump_sei_unregistered_metadata(ctx, sd); + break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd->type, sd->size);