[FFmpeg-soc] [soc]: r1200 - in jpeg2000: j2k.c j2k.h j2kdec.c j2kenc.c

k.nowosad subversion at mplayerhq.hu
Mon Aug 27 14:10:21 CEST 2007


Author: k.nowosad
Date: Mon Aug 27 14:10:21 2007
New Revision: 1200

Log:
merged common cleanup and replaced av_free with av_freep


Modified:
   jpeg2000/j2k.c
   jpeg2000/j2k.h
   jpeg2000/j2kdec.c
   jpeg2000/j2kenc.c

Modified: jpeg2000/j2k.c
==============================================================================
--- jpeg2000/j2k.c	(original)
+++ jpeg2000/j2k.c	Mon Aug 27 14:10:21 2007
@@ -358,3 +358,27 @@ void ff_j2k_reinit(J2kComponent *comp, J
         }
     }
 }
+
+void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty)
+{
+    int reslevelno, bandno, precno;
+    for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
+        J2kResLevel *reslevel = comp->reslevel + reslevelno;
+
+        for (bandno = 0; bandno < reslevel->nbands ; bandno++){
+            J2kBand *band = reslevel->band + bandno;
+                for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){
+                    J2kPrec *prec = band->prec + precno;
+                    av_freep(&prec->zerobits);
+                    av_freep(&prec->cblkincl);
+                }
+                av_freep(&band->cblk);
+                av_freep(&band->prec);
+            }
+        av_freep(&reslevel->band);
+    }
+
+    ff_dwt_destroy(&comp->dwt);
+    av_freep(&comp->reslevel);
+    av_freep(&comp->data);
+}

Modified: jpeg2000/j2k.h
==============================================================================
--- jpeg2000/j2k.h	(original)
+++ jpeg2000/j2k.h	Mon Aug 27 14:10:21 2007
@@ -213,5 +213,6 @@ static inline int ff_j2k_getsgnctxno(int
 
 int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps);
 void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty);
+void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty);
 
 #endif /* J2K_H */

Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c	(original)
+++ jpeg2000/j2kdec.c	Mon Aug 27 14:10:21 2007
@@ -808,34 +808,17 @@ static int decode_tile(J2kDecoderContext
 
 static void cleanup(J2kDecoderContext *s)
 {
-    int tileno, compno, reslevelno, bandno, precno;
+    int tileno, compno;
     for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){
         for (compno = 0; compno < s->ncomponents; compno++){
             J2kComponent *comp = s->tile[tileno].comp + compno;
             J2kCodingStyle *codsty = s->tile[tileno].codsty + compno;
 
-            for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
-                J2kResLevel *reslevel = comp->reslevel + reslevelno;
-
-                for (bandno = 0; bandno < reslevel->nbands ; bandno++){
-                    J2kBand *band = reslevel->band + bandno;
-
-                    for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){
-                        J2kPrec *prec = band->prec + precno;
-                        av_free(prec->zerobits);
-                        av_free(prec->cblkincl);
-                    }
-                    av_free(band->cblk);
-                    av_free(band->prec);
-                }
-                av_free(reslevel->band);
-            }
-            av_free(comp->reslevel);
-            ff_dwt_destroy(&comp->dwt);
+            ff_j2k_cleanup(comp, codsty);
         }
-        av_free(s->tile[tileno].comp);
+        av_freep(&s->tile[tileno].comp);
     }
-    av_free(s->tile);
+    av_freep(&s->tile);
 }
 
 static int decode_codestream(J2kDecoderContext *s)

Modified: jpeg2000/j2kenc.c
==============================================================================
--- jpeg2000/j2kenc.c	(original)
+++ jpeg2000/j2kenc.c	Mon Aug 27 14:10:21 2007
@@ -826,35 +826,17 @@ static int encode_tile(J2kEncoderContext
 
 void cleanup(J2kEncoderContext *s)
 {
-    int tileno, compno, reslevelno, bandno, precno;
+    int tileno, compno;
     J2kCodingStyle *codsty = &s->codsty;
 
     for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){
         for (compno = 0; compno < s->ncomponents; compno++){
             J2kComponent *comp = s->tile[tileno].comp + compno;
-
-            for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
-                J2kResLevel *reslevel = comp->reslevel + reslevelno;
-
-                for (bandno = 0; bandno < reslevel->nbands ; bandno++){
-                    J2kBand *band = reslevel->band + bandno;
-                        for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){
-                            J2kPrec *prec = band->prec + precno;
-                            av_free(prec->zerobits);
-                            av_free(prec->cblkincl);
-                        }
-                        av_free(band->cblk);
-                        av_free(band->prec);
-                    }
-                av_free(reslevel->band);
-            }
-            ff_dwt_destroy(&comp->dwt);
-            av_free(comp->reslevel);
-            av_free(comp->data);
+            ff_j2k_cleanup(comp, codsty);
         }
-        av_free(s->tile[tileno].comp);
+        av_freep(&s->tile[tileno].comp);
     }
-    av_free(s->tile);
+    av_freep(&s->tile);
 }
 
 static void reinit(J2kEncoderContext *s)



More information about the FFmpeg-soc mailing list