diff mbox

[FFmpeg-devel] matroskadec: cosmetics: Rearrange checks for projection-depedendent properties

Message ID 20170307223518.36948-1-vittorio.giovara@gmail.com
State Accepted
Commit 9ae3506696badc226a4e73a35009de17aeee14ce
Headers show

Commit Message

Vittorio Giovara March 7, 2017, 10:35 p.m. UTC
---
... and this chunk for matroska too.
Vittorio

 libavformat/matroskadec.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

Comments

James Almer March 7, 2017, 11:09 p.m. UTC | #1
On 3/7/2017 7:35 PM, Vittorio Giovara wrote:
> ---
> ... and this chunk for matroska too.
> Vittorio
> 
>  libavformat/matroskadec.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index fdc3f268aa..fdb23ab05e 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1930,9 +1930,7 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
>  
>      switch (track->video.projection.type) {
>      case MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR:
> -        if (track->video.projection.private.size == 0)
> -            projection = AV_SPHERICAL_EQUIRECTANGULAR;
> -        else if (track->video.projection.private.size == 20) {
> +        if (track->video.projection.private.size == 20) {
>              t = bytestream2_get_be32(&gb);
>              b = bytestream2_get_be32(&gb);
>              l = bytestream2_get_be32(&gb);
> @@ -1946,15 +1944,15 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
>                         l, t, r, b);
>                  return AVERROR_INVALIDDATA;
>              }
> -
> -            if (l || t || r || b)
> -                projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
> -            else
> -                projection = AV_SPHERICAL_EQUIRECTANGULAR;
> -        } else {
> +        } else if (track->video.projection.private.size != 0) {
>              av_log(NULL, AV_LOG_ERROR, "Unknown spherical metadata\n");
>              return AVERROR_INVALIDDATA;
>          }
> +
> +        if (l || t || r || b)
> +            projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
> +        else
> +            projection = AV_SPHERICAL_EQUIRECTANGULAR;
>          break;
>      case MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP:
>          if (track->video.projection.private.size < 4) {
> @@ -1962,13 +1960,12 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
>              return AVERROR_INVALIDDATA;
>          } else if (track->video.projection.private.size == 12) {
>              uint32_t layout = bytestream2_get_be32(&gb);
> -            if (layout == 0) {
> -                projection = AV_SPHERICAL_CUBEMAP;
> -            } else {
> +            if (layout) {
>                  av_log(NULL, AV_LOG_WARNING,
>                         "Unknown spherical cubemap layout %"PRIu32"\n", layout);
>                  return 0;
>              }
> +            projection = AV_SPHERICAL_CUBEMAP;
>              padding = bytestream2_get_be32(&gb);
>          } else {
>              av_log(NULL, AV_LOG_ERROR, "Unknown spherical metadata\n");
> 

LGTM
diff mbox

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index fdc3f268aa..fdb23ab05e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1930,9 +1930,7 @@  static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
 
     switch (track->video.projection.type) {
     case MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR:
-        if (track->video.projection.private.size == 0)
-            projection = AV_SPHERICAL_EQUIRECTANGULAR;
-        else if (track->video.projection.private.size == 20) {
+        if (track->video.projection.private.size == 20) {
             t = bytestream2_get_be32(&gb);
             b = bytestream2_get_be32(&gb);
             l = bytestream2_get_be32(&gb);
@@ -1946,15 +1944,15 @@  static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
                        l, t, r, b);
                 return AVERROR_INVALIDDATA;
             }
-
-            if (l || t || r || b)
-                projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
-            else
-                projection = AV_SPHERICAL_EQUIRECTANGULAR;
-        } else {
+        } else if (track->video.projection.private.size != 0) {
             av_log(NULL, AV_LOG_ERROR, "Unknown spherical metadata\n");
             return AVERROR_INVALIDDATA;
         }
+
+        if (l || t || r || b)
+            projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
+        else
+            projection = AV_SPHERICAL_EQUIRECTANGULAR;
         break;
     case MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP:
         if (track->video.projection.private.size < 4) {
@@ -1962,13 +1960,12 @@  static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
             return AVERROR_INVALIDDATA;
         } else if (track->video.projection.private.size == 12) {
             uint32_t layout = bytestream2_get_be32(&gb);
-            if (layout == 0) {
-                projection = AV_SPHERICAL_CUBEMAP;
-            } else {
+            if (layout) {
                 av_log(NULL, AV_LOG_WARNING,
                        "Unknown spherical cubemap layout %"PRIu32"\n", layout);
                 return 0;
             }
+            projection = AV_SPHERICAL_CUBEMAP;
             padding = bytestream2_get_be32(&gb);
         } else {
             av_log(NULL, AV_LOG_ERROR, "Unknown spherical metadata\n");