~ubuntu-branches/ubuntu/lucid/mkvtoolnix/lucid

« back to all changes in this revision

Viewing changes to src/input/r_matroska.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Clément Stenac
  • Date: 2007-05-17 11:18:27 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517111827-asq9dnnx1r9gjym2
Tags: 2.0.2-1
* New upstream bugfix version
* Use liblzo2, thanks to Peter Eisentraut (Closes:#423361)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
   see the file COPYING for details
7
7
   or visit http://www.gnu.org/copyleft/gpl.html
8
8
 
9
 
   $Id: r_matroska.cpp 3431 2007-01-05 11:15:51Z mosu $
 
9
   $Id: r_matroska.cpp 3493 2007-02-19 08:52:27Z mosu $
10
10
 
11
11
   Matroska reader
12
12
 
1434
1434
    switch (t->type) {
1435
1435
      case 'v':
1436
1436
        if ((t->codec_id == MKV_V_MSCOMP) &&
1437
 
            mpeg4::p10::is_avc_fourcc(t->v_fourcc))
1438
 
          create_mpeg4_p10_es_video_packetizer(t);
 
1437
            mpeg4::p10::is_avc_fourcc(t->v_fourcc) &&
 
1438
            !hack_engaged(ENGAGE_ALLOW_AVC_IN_VFW_MODE))
 
1439
          create_mpeg4_p10_es_video_packetizer(t, nti);
1439
1440
 
1440
1441
        else if (starts_with(t->codec_id, "V_MPEG4", 7) ||
1441
1442
                 (t->codec_id == MKV_V_MSCOMP) ||
1757
1758
}
1758
1759
 
1759
1760
void
1760
 
kax_reader_c::create_mpeg4_p10_es_video_packetizer(kax_track_t *t) {
 
1761
kax_reader_c::create_mpeg4_p10_es_video_packetizer(kax_track_t *t,
 
1762
                                                   track_info_c &nti) {
1761
1763
  try {
1762
1764
    read_first_frame(t);
1763
1765
    if (NULL == t->first_frame_data.get())
1785
1787
 
1786
1788
    mpeg4_p10_es_video_packetizer_c *ptzr =
1787
1789
      new mpeg4_p10_es_video_packetizer_c(this, avcc, t->v_width, t->v_height,
1788
 
                                          ti);
 
1790
                                          nti);
1789
1791
    t->ptzr = add_packetizer(ptzr);
1790
1792
    ptzr->enable_timecode_generation(false);
1791
1793
    if (t->default_duration)
1953
1955
  KaxReferenceBlock *ref_block;
1954
1956
  KaxBlockDuration *duration;
1955
1957
  KaxClusterTimecode *ctc;
 
1958
  KaxCodecState *codec_state;
1956
1959
  int64_t block_fref, block_bref, block_duration, frame_duration;
1957
1960
  uint64_t blockadd_id;
1958
1961
  kax_track_t *block_track;
2186
2189
            if (appending)
2187
2190
              last_timecode -= first_timecode;
2188
2191
 
 
2192
            codec_state = static_cast<KaxCodecState *>
 
2193
              (block_group->FindFirstElt(KaxCodecState::ClassInfos));
 
2194
            if ((NULL != codec_state) && !hack_engaged(ENGAGE_USE_CODEC_STATE))
 
2195
              mxerror(FMT_TID "This track uses a Matroska feature called "
 
2196
                      "'Codec state elements'. mkvmerge supports these but "
 
2197
                      "this feature has not been turned on with the option "
 
2198
                      "'--engage use_codec_state'.\n", ti.fname.c_str(),
 
2199
                      (int64_t)block_track->tnum);
 
2200
 
2189
2201
            if ((block_track->ptzr != -1) && block_track->passthrough) {
2190
2202
              // The handling for passthrough is a bit different. We don't have
2191
2203
              // any special cases, e.g. 0 terminating a string for the subs
2203
2215
                               last_timecode + i * frame_duration,
2204
2216
                               block_duration, block_bref, block_fref);
2205
2217
                packet->duration_mandatory = duration != NULL;
 
2218
                if (NULL != codec_state)
 
2219
                  packet->codec_state = clone_memory(codec_state->GetBuffer(),
 
2220
                                                     codec_state->GetSize());
2206
2221
                ((passthrough_packetizer_c *)PTZR(block_track->ptzr))->
2207
2222
                  process(packet_cptr(packet));
2208
2223
              }
2234
2249
                    lines = (char *)safemalloc(data->get_size() + 1);
2235
2250
                    lines[data->get_size()] = 0;
2236
2251
                    memcpy(lines, data->get(), data->get_size());
2237
 
                    PTZR(block_track->ptzr)->
2238
 
                      process(new packet_t(new memory_c((unsigned char *)lines,
2239
 
                                                        0, true),
2240
 
                                           last_timecode, block_duration,
2241
 
                                           block_bref, block_fref));
 
2252
 
 
2253
                    packet_t *packet =
 
2254
                      new packet_t(new memory_c((unsigned char *)lines, 0,
 
2255
                                                true),
 
2256
                                   last_timecode, block_duration,
 
2257
                                   block_bref, block_fref);
 
2258
                    if (NULL != codec_state)
 
2259
                      packet->codec_state =
 
2260
                        clone_memory(codec_state->GetBuffer(),
 
2261
                                     codec_state->GetSize());
 
2262
                    PTZR(block_track->ptzr)->process(packet);
2242
2263
                  }
2243
2264
                } else {
2244
2265
                  packet_cptr packet(new packet_t(data, last_timecode + i *
2246
2267
                                                  block_duration, block_bref,
2247
2268
                                                  block_fref));
2248
2269
 
 
2270
                  if (NULL != codec_state)
 
2271
                    packet->codec_state =
 
2272
                      clone_memory(codec_state->GetBuffer(),
 
2273
                                   codec_state->GetSize());
2249
2274
                  if (blockadd) {
2250
2275
                    for (i = 0; i < blockadd->ListSize(); i++) {
2251
2276
                      if (!(is_id((*blockadd)[i], KaxBlockMore)))
2264
2289
                        reverse(blockadded, CONTENT_ENCODING_SCOPE_BLOCK);
2265
2290
                      packet->data_adds.push_back(blockadded);
2266
2291
                    }
2267
 
 
2268
 
                    PTZR(block_track->ptzr)->process(packet);
2269
 
 
2270
 
                  } else
2271
 
                    PTZR(block_track->ptzr)->process(packet);
 
2292
                  }
 
2293
 
 
2294
                  PTZR(block_track->ptzr)->process(packet);
2272
2295
                }
2273
2296
              }
2274
2297
 
2389
2412
          info += mxsprintf("stereo_mode:%d ", (int)tracks[i]->v_stereo_mode);
2390
2413
        info += mxsprintf("default_track:%u ",
2391
2414
                          tracks[i]->default_track ? 1 : 0);
 
2415
 
 
2416
        if ((tracks[i]->codec_id == MKV_V_MSCOMP) &&
 
2417
            mpeg4::p10::is_avc_fourcc(tracks[i]->v_fourcc))
 
2418
          info += "uses_avc_es_packetizer ";
 
2419
 
2392
2420
        info += "]";
2393
2421
      } else
2394
2422
        info = "";