~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_codecs/ADM_mpeg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include <string.h>
35
35
//#include <math.h>
36
 
#include "ADM_library/default.h"
 
36
#include "ADM_utilities/default.h"
37
37
#include "avifmt.h"
38
38
#include "avifmt2.h"
39
 
#include "ADM_library/fourcc.h"
 
39
#include "fourcc.h"
40
40
#include "ADM_toolkit/toolkit.hxx"
41
41
#include "ADM_codecs/ADM_codec.h"
42
42
#include "ADM_codecs/ADM_mpeg.h"
45
45
 
46
46
extern "C"
47
47
{
48
 
#include "libMpeg2Dec/video_out.h"
 
48
#include "ADM_libMpeg2Dec/video_out.h"
49
49
#undef free
50
50
#undef alloc
51
51
#undef realloc
52
52
 
53
 
#include "libMpeg2Dec/mpeg2.h"
54
 
#include "libMpeg2Dec/mpeg2_internal.h"
 
53
#include "ADM_libMpeg2Dec/mpeg2.h"
 
54
#include "ADM_libMpeg2Dec/mpeg2_internal.h"
55
55
#include <ADM_assert.h>
56
 
#include "ADM_toolkit/ADM_debugID.h"
 
56
#include "ADM_osSupport/ADM_debugID.h"
57
57
#define MODULE_NAME MODULE_CODEC
58
 
#include "ADM_toolkit/ADM_debug.h"
 
58
#include "ADM_osSupport/ADM_debug.h"
59
59
 
60
60
 
61
61
  extern void mpeg2_pop (mpeg2dec_t * m);
83
83
  uint8_t *buffer;
84
84
} yv12_instance_t;
85
85
 
86
 
static uint8_t *iBuff[3];
87
 
static uint8_t *oBuff[3];
88
 
static int strideTab[3], strideTab2[3];
89
 
 
90
 
decoderMpeg::~decoderMpeg ()
 
86
decoderMpeg::~decoderMpeg()
91
87
{
92
 
#warning clean up libmpeg2 here
93
 
  kill_codec ();
94
 
  delete[]unpackBuffer;
 
88
        kill_codec();
 
89
        delete[] unpackBuffer;
 
90
 
 
91
        if (_seqHeader)
 
92
        {
 
93
                delete[] _seqHeader;
 
94
                _seqHeader = NULL;
 
95
        }
95
96
}
96
97
//____________________________________
97
98
uint8_t decoderMpeg::isMpeg1 (void)
116
117
  mpeg2_close (MPEG2DEC);
117
118
  _decoder = NULL;
118
119
  yv12_close (output);
 
120
  output = NULL;
119
121
 
120
122
  return 1;
121
123
}
132
134
                Constructor for mpeg decoder
133
135
______________________________________________________________________________________
134
136
*/
135
 
decoderMpeg::decoderMpeg (uint32_t w, uint32_t h, uint32_t extraLen, uint8_t * extraData):decoders (w,
136
 
          h)
 
137
decoderMpeg::decoderMpeg (uint32_t w, uint32_t h, uint32_t extraLen, uint8_t * extraData) : decoders (w,h)
137
138
{
138
 
  mpeg2_decoder_t *
139
 
    dec;
140
 
  uint32_t wmb, hmb;
141
 
  yv12_instance_t *
142
 
    inst;
143
 
  _seqLen = extraLen;
144
 
  if (extraLen)
145
 
    {
146
 
      _seqHeader = new uint8_t[extraLen];
147
 
      memcpy (_seqHeader, extraData, extraLen);
148
 
    }
149
 
  else
150
 
    {
151
 
      _seqHeader = NULL;
152
 
    }
153
 
  // store for future use
154
 
  _seqFound = 0;
155
 
  par_width=par_height=1;
156
 
  postprocessed = NULL;
157
 
  // now init libmpeg2
158
 
  printf ("\n initializing mpeg2 decoder %lu x %lu\n", _w, _h);
159
 
  output = yv12_open ();
160
 
  inst = (yv12_instance_t *) output;
161
 
  unpackBuffer = new uint8_t[(w * h * 9) >> 1];
162
 
  inst->buffer = unpackBuffer;
163
 
  _decoder = mpeg2_init ();
164
 
  dec = &((MPEG2DEC)->decoder);
165
 
  wmb = (_w + 15) >> 4;;
166
 
  hmb = (_h + 15) >> 4;;
167
 
  dec->quant_stride = wmb;
168
 
  dec->quant = (int8_t *) ADM_alloc ((wmb * hmb) * sizeof (int8_t));
169
 
  //
170
 
  feedData (extraLen, _seqHeader);
171
 
  feedData (extraLen, _seqHeader);
172
 
 
173
 
  // Post processing settings
174
 
  //___________________________
175
 
 
176
 
  _swapUV = 0;
177
 
  // Post Proc is disabled by default
178
 
 
179
 
  printf ("\n done\n");
180
 
 
 
139
        mpeg2_decoder_t *dec;
 
140
        uint32_t wmb, hmb;
 
141
        yv12_instance_t *inst;
 
142
 
 
143
        _seqLen = extraLen;
 
144
 
 
145
        if (extraLen)
 
146
        {
 
147
                _seqHeader = new uint8_t[extraLen];
 
148
                memcpy (_seqHeader, extraData, extraLen);
 
149
        }
 
150
        else
 
151
                _seqHeader = NULL;
 
152
 
 
153
        // store for future use
 
154
        _seqFound = 0;
 
155
        par_width=par_height=1;
 
156
 
 
157
        printf ("\nInitializing MPEG2 decoder %lu x %lu\n", _w, _h);
 
158
        output = yv12_open ();
 
159
        inst = (yv12_instance_t *) output;
 
160
        unpackBuffer = new uint8_t[(w * h * 9) >> 1];
 
161
        inst->buffer = unpackBuffer;
 
162
        _decoder = mpeg2_init();
 
163
        dec = &((MPEG2DEC)->decoder);
 
164
 
 
165
        wmb = (_w + 15) >> 4;;
 
166
        hmb = (_h + 15) >> 4;;
 
167
 
 
168
        dec->quant_stride = wmb;
 
169
        dec->quant = (int8_t *)ADM_alloc ((wmb * hmb) * sizeof (int8_t));
 
170
 
 
171
        feedData (extraLen, _seqHeader);
 
172
        feedData (extraLen, _seqHeader);
 
173
 
 
174
        // Post processing settings
 
175
        _swapUV = 0;
 
176
        // Post Proc is disabled by default
 
177
 
 
178
        printf ("\nDone\n");
181
179
}
182
180
/*------------------------------------------------------------------*/
183
181
uint8_t
184
 
  decoderMpeg::uncompress (uint8_t * in, ADMImage * out, uint32_t len,
185
 
                           uint32_t * flag)
 
182
  decoderMpeg::uncompress  (ADMCompressedImage * in, ADMImage * out)
186
183
{
187
 
  if (flag)
188
 
    *flag = 0;
 
184
  
 
185
    out->flags = 0;
189
186
#if defined( REMOVE_PADDING)
190
187
  while (*(in + len - 1) == 0)
191
188
    len--;
192
189
#endif
193
 
  if (!len)
 
190
  if (!in->dataLength)
194
191
    {
195
192
      if (!dontcopy ())
196
193
        return 1;
197
194
    }
198
 
  if (len)
199
 
    feedData (len, in);
 
195
  if (in->dataLength)
 
196
    feedData (in->dataLength, in->data);
200
197
 
201
198
  const mpeg2_info_t *info;
202
199
  uint8_t *t;
259
256
      //return 0;
260
257
      out->flags = 0;
261
258
    }
262
 
  if (flag)
263
 
    {
264
 
      *flag = out->flags;
265
 
    }
266
259
  if (MPEG2DEC->ext_state & PIC_FLAG_PROGRESSIVE_FRAME)
267
260
    {
268
261
      aprintf ("Progressive\n");
416
409
void
417
410
yv12_close (vo_instance_t * _instance)
418
411
{
419
 
  UNUSED_ARG (_instance);
420
 
  printf (" yv12close called\n");
 
412
        delete _instance;
 
413
        printf ("yv12close called\n");
421
414
}
422
415
 
423
416
/**