diff mbox series

[FFmpeg-devel,v5,2/5] lavc/avs3: add AVS3 related definitions

Message ID 20200819062556.1396-3-hwrenx@126.com
State Superseded
Headers show
Series Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

hwren Aug. 19, 2020, 6:25 a.m. UTC
From: hwren <hwrenx@126.com>

Signed-off-by: hwren <hwrenx@126.com>
---
 libavcodec/Makefile |  2 +
 libavcodec/avs3.c   | 95 +++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/avs3.h   | 52 +++++++++++++++++++++++++
 3 files changed, 149 insertions(+)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h

Comments

Nicolas George Aug. 19, 2020, 12:56 p.m. UTC | #1
hwrenx@126.com (12020-08-19):
> From: hwren <hwrenx@126.com>
> 
> Signed-off-by: hwren <hwrenx@126.com>
> ---
>  libavcodec/Makefile |  2 +
>  libavcodec/avs3.c   | 95 +++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/avs3.h   | 52 +++++++++++++++++++++++++
>  3 files changed, 149 insertions(+)
>  create mode 100644 libavcodec/avs3.c
>  create mode 100644 libavcodec/avs3.h

Except ff_avs3_frame_rate_tab, all these tables are only used in the
decoder. Is there a reason you want them in a separate header?

Regards,
Andreas Rheinhardt Aug. 19, 2020, 1:15 p.m. UTC | #2
hwrenx@126.com:
> From: hwren <hwrenx@126.com>
> 
> Signed-off-by: hwren <hwrenx@126.com>
> ---
>  libavcodec/Makefile |  2 +
>  libavcodec/avs3.c   | 95 +++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/avs3.h   | 52 +++++++++++++++++++++++++
>  3 files changed, 149 insertions(+)
>  create mode 100644 libavcodec/avs3.c
>  create mode 100644 libavcodec/avs3.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 3431ba2dca..e1e0c4629d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -6,6 +6,7 @@ HEADERS = ac3_parser.h                                                  \
>            avcodec.h                                                     \
>            avdct.h                                                       \
>            avfft.h                                                       \
> +          avs3.h                                                        \
>            bsf.h                                                         \
>            codec.h                                                       \
>            codec_desc.h                                                  \
> @@ -32,6 +33,7 @@ OBJS = ac3_parser.o                                                     \
>         avdct.o                                                          \
>         avpacket.o                                                       \
>         avpicture.o                                                      \
> +       avs3.o                                                           \
>         bitstream.o                                                      \
>         bitstream_filter.o                                               \
>         bitstream_filters.o                                              \
> diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
> new file mode 100644
> index 0000000000..8587e36def
> --- /dev/null
> +++ b/libavcodec/avs3.c
> @@ -0,0 +1,95 @@
> +/*
> + * AVS3 related definition
> + *
> + * Copyright (C) 2020 Huiwen Ren, <hwrenx@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "avs3.h"
> +
> +const AVRational ff_avs3_frame_rate_tab[16] = {
> +    { 0    , 0   }, // forbid
> +    { 24000, 1001},
> +    { 24   , 1   },
> +    { 25   , 1   },
> +    { 30000, 1001},
> +    { 30   , 1   },
> +    { 50   , 1   },
> +    { 60000, 1001},
> +    { 60   , 1   },
> +    { 100  , 1   },
> +    { 120  , 1   },
> +    { 200  , 1   },
> +    { 240  , 1   },
> +    { 300  , 1   },
> +    { 0    , 0   }, // reserved
> +    { 0    , 0   }  // reserved
> +};
> +
> +const int ff_avs3_color_primaries_tab[10] = {
> +    AVCOL_PRI_RESERVED0   ,    // 0
> +    AVCOL_PRI_BT709       ,    // 1
> +    AVCOL_PRI_UNSPECIFIED ,    // 2
> +    AVCOL_PRI_RESERVED    ,    // 3
> +    AVCOL_PRI_BT470M      ,    // 4
> +    AVCOL_PRI_BT470BG     ,    // 5
> +    AVCOL_PRI_SMPTE170M   ,    // 6
> +    AVCOL_PRI_SMPTE240M   ,    // 7
> +    AVCOL_PRI_FILM        ,    // 8
> +    AVCOL_PRI_BT2020           // 9
> +};
> +
> +const enum AVPictureType ff_avs3_image_type[4] = {
> +    AV_PICTURE_TYPE_NONE,
> +    AV_PICTURE_TYPE_I,
> +    AV_PICTURE_TYPE_P,
> +    AV_PICTURE_TYPE_B
> +};

These two coincide with the values of the constants, so they could be
removed.

> \ No newline at end of file

This should be fixed.

- Andreas
Moritz Barsnick Aug. 19, 2020, 2:18 p.m. UTC | #3
On Wed, Aug 19, 2020 at 14:25:53 +0800, hwrenx@126.com wrote:
> + * AVS3 related definition

definitions?
> +};
> \ No newline at end of file

Please amend a carriage return to the last line.

> + *  AVS3 related definition

definitions?

Moritz
hwren Aug. 20, 2020, 5:23 a.m. UTC | #4
At 2020-08-19 20:56:27, "Nicolas George" <george@nsup.org> wrote:
>hwrenx@126.com (12020-08-19):
>> From: hwren <hwrenx@126.com>
>> 
>> Signed-off-by: hwren <hwrenx@126.com>
>> ---
>>  libavcodec/Makefile |  2 +
>>  libavcodec/avs3.c   | 95 +++++++++++++++++++++++++++++++++++++++++++++
>>  libavcodec/avs3.h   | 52 +++++++++++++++++++++++++
>>  3 files changed, 149 insertions(+)
>>  create mode 100644 libavcodec/avs3.c
>>  create mode 100644 libavcodec/avs3.h
>
>Except ff_avs3_frame_rate_tab, all these tables are only used in the
>decoder. Is there a reason you want them in a separate header?

Considering that the other tables are also declared in AVS3, and they may get
reused by other coming encoders or decoders, so I put them together with the
ff_avs3_frame_rate_tab in avs3.h.

Thanks.
Huiwen Ren

>
>Regards,
>
>-- 
>  Nicolas George
hwren Aug. 20, 2020, 5:24 a.m. UTC | #5
At 2020-08-19 22:18:52, "Moritz Barsnick" <barsnick@gmx.net> wrote:
>On Wed, Aug 19, 2020 at 14:25:53 +0800, hwrenx@126.com wrote:
>> + * AVS3 related definition
>
>definitions?
>> +};
>> \ No newline at end of file
>
>Please amend a carriage return to the last line.
>
>> + *  AVS3 related definition
>
>definitions?
>
>Moritz

Will be corrected. Thanks for pointing out.

Regards,
Huiwen Ren

>_______________________________________________
>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".
hwren Aug. 20, 2020, 6:25 a.m. UTC | #6
At 2020-08-19 21:15:32, "Andreas Rheinhardt" <andreas.rheinhardt@gmail.com> wrote:
>hwrenx@126.com:
>> From: hwren <hwrenx@126.com>
>> 
>> Signed-off-by: hwren <hwrenx@126.com>
>> ---
>>  libavcodec/Makefile |  2 +
>>  libavcodec/avs3.c   | 95 +++++++++++++++++++++++++++++++++++++++++++++
>>  libavcodec/avs3.h   | 52 +++++++++++++++++++++++++
>>  3 files changed, 149 insertions(+)
>>  create mode 100644 libavcodec/avs3.c
>>  create mode 100644 libavcodec/avs3.h
>> 
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index 3431ba2dca..e1e0c4629d 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -6,6 +6,7 @@ HEADERS = ac3_parser.h                                                  \
>>            avcodec.h                                                     \
>>            avdct.h                                                       \
>>            avfft.h                                                       \
>> +          avs3.h                                                        \
>>            bsf.h                                                         \
>>            codec.h                                                       \
>>            codec_desc.h                                                  \
>> @@ -32,6 +33,7 @@ OBJS = ac3_parser.o                                                     \
>>         avdct.o                                                          \
>>         avpacket.o                                                       \
>>         avpicture.o                                                      \
>> +       avs3.o                                                           \
>>         bitstream.o                                                      \
>>         bitstream_filter.o                                               \
>>         bitstream_filters.o                                              \
>> diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
>> new file mode 100644
>> index 0000000000..8587e36def
>> --- /dev/null
>> +++ b/libavcodec/avs3.c
>> @@ -0,0 +1,95 @@
>> +/*
>> + * AVS3 related definition
>> + *
>> + * Copyright (C) 2020 Huiwen Ren, <hwrenx@gmail.com>
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>> + */
>> +
>> +#include "avs3.h"
>> +
>> +const AVRational ff_avs3_frame_rate_tab[16] = {
>> +    { 0    , 0   }, // forbid
>> +    { 24000, 1001},
>> +    { 24   , 1   },
>> +    { 25   , 1   },
>> +    { 30000, 1001},
>> +    { 30   , 1   },
>> +    { 50   , 1   },
>> +    { 60000, 1001},
>> +    { 60   , 1   },
>> +    { 100  , 1   },
>> +    { 120  , 1   },
>> +    { 200  , 1   },
>> +    { 240  , 1   },
>> +    { 300  , 1   },
>> +    { 0    , 0   }, // reserved
>> +    { 0    , 0   }  // reserved
>> +};
>> +
>> +const int ff_avs3_color_primaries_tab[10] = {
>> +    AVCOL_PRI_RESERVED0   ,    // 0
>> +    AVCOL_PRI_BT709       ,    // 1
>> +    AVCOL_PRI_UNSPECIFIED ,    // 2
>> +    AVCOL_PRI_RESERVED    ,    // 3
>> +    AVCOL_PRI_BT470M      ,    // 4
>> +    AVCOL_PRI_BT470BG     ,    // 5
>> +    AVCOL_PRI_SMPTE170M   ,    // 6
>> +    AVCOL_PRI_SMPTE240M   ,    // 7
>> +    AVCOL_PRI_FILM        ,    // 8
>> +    AVCOL_PRI_BT2020           // 9
>> +};
>> +
>> +const enum AVPictureType ff_avs3_image_type[4] = {
>> +    AV_PICTURE_TYPE_NONE,
>> +    AV_PICTURE_TYPE_I,
>> +    AV_PICTURE_TYPE_P,
>> +    AV_PICTURE_TYPE_B
>> +};
>
>These two coincide with the values of the constants, so they could be
>removed.

Indeed. But I prefer to keep these mappings in case any side changes their related tables,
and ensure the completeness of the group of definitions. These table may also help to
check the validity of the type value and describe supported range in AVS3.

Thanks.

>
>> \ No newline at end of file
>
>This should be fixed.

Will be fixed. Thanks.

Regards,
Huiwen Ren

>
>- Andreas
>_______________________________________________
>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".
Moritz Barsnick Aug. 26, 2020, 11:50 a.m. UTC | #7
On Thu, Aug 20, 2020 at 13:24:44 +0800, hwren wrote:
> At 2020-08-19 22:18:52, "Moritz Barsnick" <barsnick@gmx.net> wrote:
> >On Wed, Aug 19, 2020 at 14:25:53 +0800, hwrenx@126.com wrote:
> >> + * AVS3 related definition
> >
> >definitions?
> >> +};
> >> \ No newline at end of file
> >
> >Please amend a carriage return to the last line.
> >
> >> + *  AVS3 related definition
> >
> >definitions?
> >
> >Moritz
>
> Will be corrected. Thanks for pointing out.

This didn't change in v7.

Moritz
diff mbox series

Patch

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..e1e0c4629d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@  HEADERS = ac3_parser.h                                                  \
           avcodec.h                                                     \
           avdct.h                                                       \
           avfft.h                                                       \
+          avs3.h                                                        \
           bsf.h                                                         \
           codec.h                                                       \
           codec_desc.h                                                  \
@@ -32,6 +33,7 @@  OBJS = ac3_parser.o                                                     \
        avdct.o                                                          \
        avpacket.o                                                       \
        avpicture.o                                                      \
+       avs3.o                                                           \
        bitstream.o                                                      \
        bitstream_filter.o                                               \
        bitstream_filters.o                                              \
diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
new file mode 100644
index 0000000000..8587e36def
--- /dev/null
+++ b/libavcodec/avs3.c
@@ -0,0 +1,95 @@ 
+/*
+ * AVS3 related definition
+ *
+ * Copyright (C) 2020 Huiwen Ren, <hwrenx@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+
+const AVRational ff_avs3_frame_rate_tab[16] = {
+    { 0    , 0   }, // forbid
+    { 24000, 1001},
+    { 24   , 1   },
+    { 25   , 1   },
+    { 30000, 1001},
+    { 30   , 1   },
+    { 50   , 1   },
+    { 60000, 1001},
+    { 60   , 1   },
+    { 100  , 1   },
+    { 120  , 1   },
+    { 200  , 1   },
+    { 240  , 1   },
+    { 300  , 1   },
+    { 0    , 0   }, // reserved
+    { 0    , 0   }  // reserved
+};
+
+const int ff_avs3_color_primaries_tab[10] = {
+    AVCOL_PRI_RESERVED0   ,    // 0
+    AVCOL_PRI_BT709       ,    // 1
+    AVCOL_PRI_UNSPECIFIED ,    // 2
+    AVCOL_PRI_RESERVED    ,    // 3
+    AVCOL_PRI_BT470M      ,    // 4
+    AVCOL_PRI_BT470BG     ,    // 5
+    AVCOL_PRI_SMPTE170M   ,    // 6
+    AVCOL_PRI_SMPTE240M   ,    // 7
+    AVCOL_PRI_FILM        ,    // 8
+    AVCOL_PRI_BT2020           // 9
+};
+
+const int ff_avs3_color_transfer_tab[15] = {
+    AVCOL_TRC_RESERVED0    , // 0
+    AVCOL_TRC_BT709        , // 1
+    AVCOL_TRC_UNSPECIFIED  , // 2
+    AVCOL_TRC_RESERVED     , // 3
+    AVCOL_TRC_GAMMA22      , // 4
+    AVCOL_TRC_GAMMA28      , // 5
+    AVCOL_TRC_SMPTE170M    , // 6
+    AVCOL_TRC_SMPTE240M    , // 7
+    AVCOL_TRC_LINEAR       , // 8
+    AVCOL_TRC_LOG          , // 9
+    AVCOL_TRC_LOG_SQRT     , // 10
+    AVCOL_TRC_BT2020_12    , // 11
+    AVCOL_TRC_SMPTE2084    , // 12
+    AVCOL_TRC_UNSPECIFIED  , // 13
+    AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+const int ff_avs3_color_matrix_tab[12] = {
+    AVCOL_SPC_RESERVED     , // 0
+    AVCOL_SPC_BT709        , // 1
+    AVCOL_SPC_UNSPECIFIED  , // 2
+    AVCOL_SPC_RESERVED     , // 3
+    AVCOL_SPC_FCC          , // 4
+    AVCOL_SPC_BT470BG      , // 5
+    AVCOL_SPC_SMPTE170M    , // 6
+    AVCOL_SPC_SMPTE240M    , // 7
+    AVCOL_SPC_BT2020_NCL   , // 8
+    AVCOL_SPC_BT2020_CL    , // 9
+    AVCOL_SPC_UNSPECIFIED  , // 10
+    AVCOL_SPC_UNSPECIFIED    // 11
+};
+
+const enum AVPictureType ff_avs3_image_type[4] = {
+    AV_PICTURE_TYPE_NONE,
+    AV_PICTURE_TYPE_I,
+    AV_PICTURE_TYPE_P,
+    AV_PICTURE_TYPE_B
+};
\ No newline at end of file
diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 0000000000..9f79adb7bf
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,52 @@ 
+/*
+ *  AVS3 related definition
+ *
+ * Copyright (C) 2020 Huiwen Ren, <hwrenx@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AVS3_H
+#define AVCODEC_AVS3_H
+
+#define AVS3_NAL_START_CODE          0x010000
+#define AVS3_SEQ_START_CODE          0xB0
+#define AVS3_SEQ_END_CODE            0xB1
+#define AVS3_USER_DATA_START_CODE    0xB2
+#define AVS3_INTRA_PIC_START_CODE    0xB3
+#define AVS3_UNDEF_START_CODE        0xB4
+#define AVS3_EXTENSION_START_CODE    0xB5
+#define AVS3_INTER_PIC_START_CODE    0xB6
+#define AVS3_VIDEO_EDIT_CODE         0xB7
+#define AVS3_FIRST_SLICE_START_CODE  0x00
+#define AVS3_PROFILE_BASELINE_MAIN   0x20
+#define AVS3_PROFILE_BASELINE_MAIN10 0x22
+
+#define ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == AVS3_INTER_PIC_START_CODE)
+#define ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || ISPIC(x))
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/rational.h"
+
+extern const AVRational ff_avs3_frame_rate_tab[16];
+extern const int ff_avs3_color_primaries_tab[10];
+extern const int ff_avs3_color_transfer_tab[15];
+extern const int ff_avs3_color_matrix_tab[12];
+extern const enum AVPictureType ff_avs3_image_type[4];
+
+#endif /* AVCODEC_AVS3_H */