diff options
Diffstat (limited to 'lib/libdv_wrapper.cc')
-rw-r--r-- | lib/libdv_wrapper.cc | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/lib/libdv_wrapper.cc b/lib/libdv_wrapper.cc index df624b6..cb9cc7c 100644 --- a/lib/libdv_wrapper.cc +++ b/lib/libdv_wrapper.cc @@ -40,6 +40,7 @@ LibDVWrapper::LibDVWrapper(DV::Quality quality, setSampling(sampling); yuv[0] = yuv[1] = yuv[2] = NULL; + pitches[0] = pitches[1] = pitches[2] = 0; width = 720; height = 576; @@ -73,56 +74,83 @@ void LibDVWrapper::setSampling(DV::Sampling sampling) decoder->sampling = (dv_sample_t)sampling; } -void LibDVWrapper::setOutputBuffer(char *output, DV::ColorSpace c) +Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c) { - colorspace = c; + if(input->vformat != VF_DV) { + fprintf(stderr, "Wrong format in LibDVWrapper, expected VF_DV, got: %i\n", input->vformat); + return NULL; + } + + /* + if(first) { + dv_parse_header(decoder, (const uint8_t*)input); + //dv_parse_packs(decoder, frame->data); // Not needed anyway! + decoder->std = e_dv_std_iec_61834; + decoder->num_dif_seqs = 12; + first = false; + } + */ + + + int size = 0; + char* buf = NULL; + int type = VF_NONE; + DV::ColorSpace colorspace = c; switch(colorspace) { case DV::YUV: #ifdef COLORSPACE_YV12 - yuv[0] = (unsigned char*)output; + size = width*height*2; + buf = (char*)malloc(size); + type = VF_YV12; + yuv[0] = (unsigned char*)buf; yuv[1] = (unsigned char*)yuv[0] + (width * height); yuv[2] = (unsigned char*)yuv[1] + (width * height / 4); pitches[0] = width; pitches[1] = width / 2; pitches[2] = width / 2; #else - yuv[0] = (unsigned char*)output; + printf("!\n"); + size = width*height*2; + buf = (char*)malloc(size); + type = VF_YUV422; + yuv[0] = (unsigned char*)buf; + yuv[1] = yuv[2] = NULL; pitches[0] = width * 2; + pitches[1] = pitches[2] = 0; #endif break; case DV::RGB: - yuv[0] = (unsigned char*)output; + size = width*height*3; + buf = (char*)malloc(size); + type = VF_RGB; + yuv[0] = (unsigned char*)buf; yuv[1] = yuv[2] = NULL; pitches[0] = width * 3; + pitches[1] = pitches[2] = 0; break; case DV::BGR0: - yuv[0] = (unsigned char*)output; + size = width*height*4; + buf = (char*)malloc(size); + type = VF_BRG0; + yuv[0] = (unsigned char*)buf; yuv[1] = yuv[2] = NULL; pitches[0] = width * 4; + pitches[1] = pitches[2] = 0; break; } -} - -void LibDVWrapper::decode(char *input) -{ - if(!yuv[0]) return; // outputbuffer not set! - /* - if(first) { - dv_parse_header(decoder, (const uint8_t*)input); - //dv_parse_packs(decoder, frame->data); // Not needed anyway! - decoder->std = e_dv_std_iec_61834; - decoder->num_dif_seqs = 12; - first = false; - } - */ dv_decode_full_frame(decoder, (const uint8_t*)input, (dv_color_space_t)colorspace, yuv, pitches); + // memset(buf, 1, width*height); + // memset(buf+width*height, 100, width*height/2); + // memset(buf+width*height+width*height/2, 200, width*height/2); + Frame *frame = new Frame(buf, size, type, NULL, 0, AF_NONE); + return frame; } |