diff mbox series

[FFmpeg-devel,libavcodec] Duckduckgo Truemotion 1 - some code cleanup and preparation for addition of sprite support

Message ID 2be15aea25f9ee8eb40285a77fa56014@lolcow.email
State New
Headers show
Series [FFmpeg-devel,libavcodec] Duckduckgo Truemotion 1 - some code cleanup and preparation for addition of sprite support | expand

Checks

Context Check Description
andriy/configure warning Failed to apply patch

Commit Message

ffmpegandmahanstreamer@lolcow.email July 4, 2021, 9:58 p.m. UTC
These are some cosmetic changes and also priming the decoder for sprite 
support (which i plan on adding). This patch was mainly for me to get 
used to the git email patch flow, if anything. Of course the decoder 
still works as it was before (i tested it).
---
  libavcodec/truemotion1.c | 41 +++++++++++++++++-----------------------
  1 file changed, 17 insertions(+), 24 deletions(-)

  #include <stdio.h>
@@ -360,8 +360,12 @@ static int 
truemotion1_decode_header(TrueMotion1Context *s)
          s->flags = FLAG_KEYFRAME;

      if (s->flags & FLAG_SPRITE) {
+        // https://wiki.multimedia.cx/index.php/Duck_TrueMotion_1
+        header.xoffset = AV_RL16(&header_buffer[13]);
+        header.yoffset = AV_RL16(&header_buffer[15]);
+        header.width = AV_RL16(&header_buffer[17]);
+        header.height = AV_RL16(&header_buffer[19]);
          avpriv_request_sample(s->avctx, "Frame with sprite");
-        /* FIXME header.width, height, xoffset and yoffset aren't 
initialized */
          return AVERROR_PATCHWELCOME;
      } else {
          s->w = header.xsize;
@@ -660,20 +664,15 @@ static void 
truemotion1_decode_16bit(TrueMotion1Context *s)
                  case 0:
                      /* if macroblock width is 2, apply C-Y-C-Y; else
                       * apply C-Y-Y */
+                    APPLY_C_PREDICTOR();
+                    APPLY_Y_PREDICTOR();
+                    OUTPUT_PIXEL_PAIR();
                      if (s->block_width == 2) {
                          APPLY_C_PREDICTOR();
-                        APPLY_Y_PREDICTOR();
-                        OUTPUT_PIXEL_PAIR();
-                        APPLY_C_PREDICTOR();
-                        APPLY_Y_PREDICTOR();
-                        OUTPUT_PIXEL_PAIR();
-                    } else {
-                        APPLY_C_PREDICTOR();
-                        APPLY_Y_PREDICTOR();
-                        OUTPUT_PIXEL_PAIR();
-                        APPLY_Y_PREDICTOR();
                          OUTPUT_PIXEL_PAIR();
                      }
+                    APPLY_Y_PREDICTOR();
+                    OUTPUT_PIXEL_PAIR();
                      break;

                  case 1:
@@ -786,20 +785,14 @@ static void 
truemotion1_decode_24bit(TrueMotion1Context *s)
                  case 0:
                      /* if macroblock width is 2, apply C-Y-C-Y; else
                       * apply C-Y-Y */
+                    APPLY_C_PREDICTOR_24();
+                    APPLY_Y_PREDICTOR_24();
+                    OUTPUT_PIXEL_PAIR();
                      if (s->block_width == 2) {
                          APPLY_C_PREDICTOR_24();
-                        APPLY_Y_PREDICTOR_24();
-                        OUTPUT_PIXEL_PAIR();
-                        APPLY_C_PREDICTOR_24();
-                        APPLY_Y_PREDICTOR_24();
-                        OUTPUT_PIXEL_PAIR();
-                    } else {
-                        APPLY_C_PREDICTOR_24();
-                        APPLY_Y_PREDICTOR_24();
-                        OUTPUT_PIXEL_PAIR();
-                        APPLY_Y_PREDICTOR_24();
-                        OUTPUT_PIXEL_PAIR();
                      }
+                    APPLY_Y_PREDICTOR_24();
+                    OUTPUT_PIXEL_PAIR();
                      break;

                  case 1:

Comments

ffmpegandmahanstreamer@lolcow.email July 14, 2021, 12:04 p.m. UTC | #1
On 2021-07-04 17:58, ffmpegandmahanstreamer@lolcow.email wrote:
> These are some cosmetic changes and also priming the decoder for
> sprite support (which i plan on adding). This patch was mainly for me
> to get used to the git email patch flow, if anything. Of course the
> decoder still works as it was before (i tested it).
> ---
>  libavcodec/truemotion1.c | 41 +++++++++++++++++-----------------------
>  1 file changed, 17 insertions(+), 24 deletions(-)
> 
> diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
> index 32d8fb4005..80946a405f 100644
> --- a/libavcodec/truemotion1.c
> +++ b/libavcodec/truemotion1.c
> @@ -23,10 +23,10 @@
>   * @file
>   * Duck TrueMotion v1 Video Decoder by
>   * Alex Beregszaszi and
> - * Mike Melanson (melanson@pcisys.net)
> + * Mike Melanson (mike@multimedia.cx)
>   *
>   * The TrueMotion v1 decoder presently only decodes 16-bit TM1 data 
> and
> - * outputs RGB555 (or RGB565) data. 24-bit TM1 data is not supported 
> yet.
> + * outputs RGB555 (or RGB565) data.
>   */
> 
>  #include <stdio.h>
> @@ -360,8 +360,12 @@ static int 
> truemotion1_decode_header(TrueMotion1Context *s)
>          s->flags = FLAG_KEYFRAME;
> 
>      if (s->flags & FLAG_SPRITE) {
> +        // https://wiki.multimedia.cx/index.php/Duck_TrueMotion_1
> +        header.xoffset = AV_RL16(&header_buffer[13]);
> +        header.yoffset = AV_RL16(&header_buffer[15]);
> +        header.width = AV_RL16(&header_buffer[17]);
> +        header.height = AV_RL16(&header_buffer[19]);
>          avpriv_request_sample(s->avctx, "Frame with sprite");
> -        /* FIXME header.width, height, xoffset and yoffset aren't
> initialized */
>          return AVERROR_PATCHWELCOME;
>      } else {
>          s->w = header.xsize;
> @@ -660,20 +664,15 @@ static void
> truemotion1_decode_16bit(TrueMotion1Context *s)
>                  case 0:
>                      /* if macroblock width is 2, apply C-Y-C-Y; else
>                       * apply C-Y-Y */
> +                    APPLY_C_PREDICTOR();
> +                    APPLY_Y_PREDICTOR();
> +                    OUTPUT_PIXEL_PAIR();
>                      if (s->block_width == 2) {
>                          APPLY_C_PREDICTOR();
> -                        APPLY_Y_PREDICTOR();
> -                        OUTPUT_PIXEL_PAIR();
> -                        APPLY_C_PREDICTOR();
> -                        APPLY_Y_PREDICTOR();
> -                        OUTPUT_PIXEL_PAIR();
> -                    } else {
> -                        APPLY_C_PREDICTOR();
> -                        APPLY_Y_PREDICTOR();
> -                        OUTPUT_PIXEL_PAIR();
> -                        APPLY_Y_PREDICTOR();
>                          OUTPUT_PIXEL_PAIR();
>                      }
> +                    APPLY_Y_PREDICTOR();
> +                    OUTPUT_PIXEL_PAIR();
>                      break;
> 
>                  case 1:
> @@ -786,20 +785,14 @@ static void
> truemotion1_decode_24bit(TrueMotion1Context *s)
>                  case 0:
>                      /* if macroblock width is 2, apply C-Y-C-Y; else
>                       * apply C-Y-Y */
> +                    APPLY_C_PREDICTOR_24();
> +                    APPLY_Y_PREDICTOR_24();
> +                    OUTPUT_PIXEL_PAIR();
>                      if (s->block_width == 2) {
>                          APPLY_C_PREDICTOR_24();
> -                        APPLY_Y_PREDICTOR_24();
> -                        OUTPUT_PIXEL_PAIR();
> -                        APPLY_C_PREDICTOR_24();
> -                        APPLY_Y_PREDICTOR_24();
> -                        OUTPUT_PIXEL_PAIR();
> -                    } else {
> -                        APPLY_C_PREDICTOR_24();
> -                        APPLY_Y_PREDICTOR_24();
> -                        OUTPUT_PIXEL_PAIR();
> -                        APPLY_Y_PREDICTOR_24();
> -                        OUTPUT_PIXEL_PAIR();
>                      }
> +                    APPLY_Y_PREDICTOR_24();
> +                    OUTPUT_PIXEL_PAIR();
>                      break;
> 
>                  case 1:
ping
diff mbox series

Patch

diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index 32d8fb4005..80946a405f 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -23,10 +23,10 @@ 
   * @file
   * Duck TrueMotion v1 Video Decoder by
   * Alex Beregszaszi and
- * Mike Melanson (melanson@pcisys.net)
+ * Mike Melanson (mike@multimedia.cx)
   *
   * The TrueMotion v1 decoder presently only decodes 16-bit TM1 data and
- * outputs RGB555 (or RGB565) data. 24-bit TM1 data is not supported 
yet.
+ * outputs RGB555 (or RGB565) data.
   */