diff mbox series

[FFmpeg-devel,5/7] avformat/segafilmenc: Remove redundant checks

Message ID 20200114031336.24096-5-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/7] avformat/segafilmenc: Fix undefined left shift of 1 by 31 places | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 14, 2020, 3:13 a.m. UTC
If an audio stream is present, the Sega FILM muxer checks for its
compability with the container during init, so that the very same check
needn't be repeated during writing the trailer.

Essentially the same is true for the presence of a video stream: It has
already been checked during init. Furthermore, after the check for the
presence of a video stream succeeded, a pointer is set to point to the
video stream. Yet said pointer (which was NULL before) will be
derefenced anyway regardless of the result of the check. Coverity thus
complained about this in CID 1434155 and removing this pointless check
will also fix this issue.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/segafilmenc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Andreas Rheinhardt Feb. 17, 2020, 3:42 p.m. UTC | #1
Andreas Rheinhardt:
> If an audio stream is present, the Sega FILM muxer checks for its
> compability with the container during init, so that the very same check
> needn't be repeated during writing the trailer.
> 
> Essentially the same is true for the presence of a video stream: It has
> already been checked during init. Furthermore, after the check for the
> presence of a video stream succeeded, a pointer is set to point to the
> video stream. Yet said pointer (which was NULL before) will be
> derefenced anyway regardless of the result of the check. Coverity thus
> complained about this in CID 1434155 and removing this pointless check
> will also fix this issue.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/segafilmenc.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
> index 5ac60ea5c3..4f881f4f2f 100644
> --- a/libavformat/segafilmenc.c
> +++ b/libavformat/segafilmenc.c
> @@ -292,15 +292,9 @@ static int film_write_header(AVFormatContext *format_context)
>  
>      if (film->audio_index > -1)
>          audio = format_context->streams[film->audio_index];
> -    if (film->video_index > -1)
> -        video = format_context->streams[film->video_index];
>  
>      if (audio != NULL) {
>          audio_codec = get_audio_codec_id(audio->codecpar->codec_id);
> -        if (audio_codec < 0) {
> -            av_log(format_context, AV_LOG_ERROR, "Incompatible audio stream format.\n");
> -            return AVERROR(EINVAL);
> -        }
>      }
>  
>      /* First, write the FILM header; this is very simple */
> @@ -317,6 +311,8 @@ static int film_write_header(AVFormatContext *format_context)
>      ffio_wfourcc(pb, "FDSC");
>      avio_wb32(pb, 0x20); /* Size of FDSC chunk */
>  
> +    video = format_context->streams[film->video_index];
> +
>      /* The only two supported codecs; raw video is rare */
>      switch (video->codecpar->codec_id) {
>      case AV_CODEC_ID_CINEPAK:
> 

Ping.

- Andreas
Andreas Rheinhardt Feb. 21, 2020, 1:06 p.m. UTC | #2
Andreas Rheinhardt:
> Andreas Rheinhardt:
>> If an audio stream is present, the Sega FILM muxer checks for its
>> compability with the container during init, so that the very same check
>> needn't be repeated during writing the trailer.
>>
>> Essentially the same is true for the presence of a video stream: It has
>> already been checked during init. Furthermore, after the check for the
>> presence of a video stream succeeded, a pointer is set to point to the
>> video stream. Yet said pointer (which was NULL before) will be
>> derefenced anyway regardless of the result of the check. Coverity thus
>> complained about this in CID 1434155 and removing this pointless check
>> will also fix this issue.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavformat/segafilmenc.c | 8 ++------
>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
>> index 5ac60ea5c3..4f881f4f2f 100644
>> --- a/libavformat/segafilmenc.c
>> +++ b/libavformat/segafilmenc.c
>> @@ -292,15 +292,9 @@ static int film_write_header(AVFormatContext *format_context)
>>  
>>      if (film->audio_index > -1)
>>          audio = format_context->streams[film->audio_index];
>> -    if (film->video_index > -1)
>> -        video = format_context->streams[film->video_index];
>>  
>>      if (audio != NULL) {
>>          audio_codec = get_audio_codec_id(audio->codecpar->codec_id);
>> -        if (audio_codec < 0) {
>> -            av_log(format_context, AV_LOG_ERROR, "Incompatible audio stream format.\n");
>> -            return AVERROR(EINVAL);
>> -        }
>>      }
>>  
>>      /* First, write the FILM header; this is very simple */
>> @@ -317,6 +311,8 @@ static int film_write_header(AVFormatContext *format_context)
>>      ffio_wfourcc(pb, "FDSC");
>>      avio_wb32(pb, 0x20); /* Size of FDSC chunk */
>>  
>> +    video = format_context->streams[film->video_index];
>> +
>>      /* The only two supported codecs; raw video is rare */
>>      switch (video->codecpar->codec_id) {
>>      case AV_CODEC_ID_CINEPAK:
>>
> 
> Ping.
> 
> - Andreas
> 
Another ping.

- Andreas
Paul B Mahol Feb. 21, 2020, 1:10 p.m. UTC | #3
lgtm

On 1/14/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> If an audio stream is present, the Sega FILM muxer checks for its
> compability with the container during init, so that the very same check
> needn't be repeated during writing the trailer.
>
> Essentially the same is true for the presence of a video stream: It has
> already been checked during init. Furthermore, after the check for the
> presence of a video stream succeeded, a pointer is set to point to the
> video stream. Yet said pointer (which was NULL before) will be
> derefenced anyway regardless of the result of the check. Coverity thus
> complained about this in CID 1434155 and removing this pointless check
> will also fix this issue.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/segafilmenc.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
> index 5ac60ea5c3..4f881f4f2f 100644
> --- a/libavformat/segafilmenc.c
> +++ b/libavformat/segafilmenc.c
> @@ -292,15 +292,9 @@ static int film_write_header(AVFormatContext
> *format_context)
>
>      if (film->audio_index > -1)
>          audio = format_context->streams[film->audio_index];
> -    if (film->video_index > -1)
> -        video = format_context->streams[film->video_index];
>
>      if (audio != NULL) {
>          audio_codec = get_audio_codec_id(audio->codecpar->codec_id);
> -        if (audio_codec < 0) {
> -            av_log(format_context, AV_LOG_ERROR, "Incompatible audio stream
> format.\n");
> -            return AVERROR(EINVAL);
> -        }
>      }
>
>      /* First, write the FILM header; this is very simple */
> @@ -317,6 +311,8 @@ static int film_write_header(AVFormatContext
> *format_context)
>      ffio_wfourcc(pb, "FDSC");
>      avio_wb32(pb, 0x20); /* Size of FDSC chunk */
>
> +    video = format_context->streams[film->video_index];
> +
>      /* The only two supported codecs; raw video is rare */
>      switch (video->codecpar->codec_id) {
>      case AV_CODEC_ID_CINEPAK:
> --
> 2.20.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".
Michael Niedermayer Feb. 22, 2020, 7:45 p.m. UTC | #4
On Fri, Feb 21, 2020 at 02:10:00PM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
index 5ac60ea5c3..4f881f4f2f 100644
--- a/libavformat/segafilmenc.c
+++ b/libavformat/segafilmenc.c
@@ -292,15 +292,9 @@  static int film_write_header(AVFormatContext *format_context)
 
     if (film->audio_index > -1)
         audio = format_context->streams[film->audio_index];
-    if (film->video_index > -1)
-        video = format_context->streams[film->video_index];
 
     if (audio != NULL) {
         audio_codec = get_audio_codec_id(audio->codecpar->codec_id);
-        if (audio_codec < 0) {
-            av_log(format_context, AV_LOG_ERROR, "Incompatible audio stream format.\n");
-            return AVERROR(EINVAL);
-        }
     }
 
     /* First, write the FILM header; this is very simple */
@@ -317,6 +311,8 @@  static int film_write_header(AVFormatContext *format_context)
     ffio_wfourcc(pb, "FDSC");
     avio_wb32(pb, 0x20); /* Size of FDSC chunk */
 
+    video = format_context->streams[film->video_index];
+
     /* The only two supported codecs; raw video is rare */
     switch (video->codecpar->codec_id) {
     case AV_CODEC_ID_CINEPAK: