diff mbox series

[FFmpeg-devel,3/3] avformat/dss: Remove unnecessary allocation

Message ID 20200402171740.19121-3-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/3] avformat/ilbc: Don't reimplement ff_raw_write_packet | expand

Checks

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

Commit Message

Andreas Rheinhardt April 2, 2020, 5:17 p.m. UTC
Put a buffer with a known fixed size into the demuxer's context instead
of allocating it separately. This also allows to remove the demuxer's
read_close()-function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/dss.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

Comments

Michael Niedermayer April 3, 2020, 2:43 p.m. UTC | #1
On Thu, Apr 02, 2020 at 07:17:40PM +0200, Andreas Rheinhardt wrote:
> Put a buffer with a known fixed size into the demuxer's context instead
> of allocating it separately. This also allows to remove the demuxer's
> read_close()-function.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/dss.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/dss.c b/libavformat/dss.c
index ae7a259526..0585049130 100644
--- a/libavformat/dss.c
+++ b/libavformat/dss.c
@@ -50,7 +50,7 @@  typedef struct DSSDemuxContext {
     int counter;
     int swap;
     int dss_sp_swap_byte;
-    int8_t *dss_sp_buf;
+    int8_t dss_sp_buf[DSS_FRAME_SIZE + 1];
 
     int packet_size;
     int dss_header_size;
@@ -168,10 +168,6 @@  static int dss_read_header(AVFormatContext *s)
     ctx->counter = 0;
     ctx->swap    = 0;
 
-    ctx->dss_sp_buf = av_malloc(DSS_FRAME_SIZE + 1);
-    if (!ctx->dss_sp_buf)
-        return AVERROR(ENOMEM);
-
     return 0;
 }
 
@@ -327,15 +323,6 @@  static int dss_read_packet(AVFormatContext *s, AVPacket *pkt)
         return dss_723_1_read_packet(s, pkt);
 }
 
-static int dss_read_close(AVFormatContext *s)
-{
-    DSSDemuxContext *ctx = s->priv_data;
-
-    av_freep(&ctx->dss_sp_buf);
-
-    return 0;
-}
-
 static int dss_read_seek(AVFormatContext *s, int stream_index,
                          int64_t timestamp, int flags)
 {
@@ -382,7 +369,6 @@  AVInputFormat ff_dss_demuxer = {
     .read_probe     = dss_probe,
     .read_header    = dss_read_header,
     .read_packet    = dss_read_packet,
-    .read_close     = dss_read_close,
     .read_seek      = dss_read_seek,
     .extensions     = "dss"
 };