コード例 #1
0
ファイル: filejpeglist.C プロジェクト: beequ7et/cinelerra-cv
int FileJPEGList::read_frame(VFrame *frame, VFrame *data)
{
	mjpeg_t *mjpeg = mjpeg_new(asset->width, 
		asset->height, 
		1);
	mjpeg_decompress(mjpeg, 
		data->get_data(), 
		data->get_compressed_size(),
		0,  
		frame->get_rows(), 
		frame->get_y(), 
		frame->get_u(), 
		frame->get_v(),
		frame->get_color_model(),
		file->cpus);
	mjpeg_delete(mjpeg);
	return 0;
}
コード例 #2
0
int RecVideoMJPGThread::render_frame(VFrame *frame, long size)
{
// printf("RecVideoMJPGThread::render_frame %d %02x%02x %02x%02x\n", 
// frame->get_field2_offset(), 
// frame->get_data()[0], 
// frame->get_data()[1], 
// frame->get_data()[frame->get_field2_offset()], 
// frame->get_data()[frame->get_field2_offset() + 1]);
//frame->set_field2_offset(0);
	mjpeg_decompress(mjpeg, 
		frame->get_data(), 
		frame->get_compressed_size(), 
		frame->get_field2_offset(), 
		thread->output_frame->get_rows(), 
		thread->output_frame->get_y(), 
		thread->output_frame->get_u(), 
		thread->output_frame->get_v(),
		thread->output_frame->get_color_model(),
		record->mwindow->preferences->processors);
	return 0;
}
コード例 #3
0
ファイル: jpeg.c プロジェクト: knutj/cinelerra
static int decode(quicktime_t *file,
                  unsigned char **row_pointers,
                  int track)
{
    quicktime_video_map_t *vtrack = &(file->vtracks[track]);
    initialize(vtrack);
    quicktime_jpeg_codec_t *codec = ((quicktime_codec_t*)vtrack->codec)->priv;
    quicktime_trak_t *trak = vtrack->track;
    mjpeg_t *mjpeg = codec->mjpeg;
    long size, field2_offset = 0;
    int track_height = trak->tkhd.track_height;
    int track_width = trak->tkhd.track_width;
    int result = 0;
    int field_dominance = trak->mdia.minf.stbl.stsd.table[0].field_dominance;

    mjpeg_set_cpus(codec->mjpeg, file->cpus);
    if(file->row_span)
        mjpeg_set_rowspan(codec->mjpeg, file->row_span);
    else
        mjpeg_set_rowspan(codec->mjpeg, 0);

    quicktime_set_video_position(file, vtrack->current_position, track);
    size = quicktime_frame_size(file, vtrack->current_position, track);
    codec->buffer_size = size;

    if(size > codec->buffer_allocated)
    {
        codec->buffer_allocated = size;
        codec->buffer = realloc(codec->buffer, codec->buffer_allocated);
    }

    result = !quicktime_read_data(file, (char*)codec->buffer, size);
    /*
     * printf("decode 1 %02x %02x %02x %02x %02x %02x %02x %02x\n",
     * codec->buffer[0],
     * codec->buffer[1],
     * codec->buffer[2],
     * codec->buffer[3],
     * codec->buffer[4],
     * codec->buffer[5],
     * codec->buffer[6],
     * codec->buffer[7]
     * );
     */

    if(!result)
    {
        if(mjpeg_get_fields(mjpeg) == 2)
        {
            if(file->use_avi)
            {
                field2_offset = mjpeg_get_avi_field2(codec->buffer,
                                                     size,
                                                     &field_dominance);
            }
            else
            {
                field2_offset = mjpeg_get_quicktime_field2(codec->buffer,
                                size);
// Sanity check
                if(!field2_offset)
                {
                    printf("decode: FYI field2_offset=0\n");
                    field2_offset = mjpeg_get_field2(codec->buffer, size);
                }
            }
        }
        else
            field2_offset = 0;


//printf("decode 2 %d\n", field2_offset);
        /*
         * printf("decode result=%d field1=%llx field2=%llx size=%d %02x %02x %02x %02x\n",
         * result,
         * quicktime_position(file) - size,
         * quicktime_position(file) - size + field2_offset,
         * size,
         * codec->buffer[0],
         * codec->buffer[1],
         * codec->buffer[field2_offset + 0],
         * codec->buffer[field2_offset + 1]);
         */

        if(file->in_x == 0 &&
                file->in_y == 0 &&
                file->in_w == track_width &&
                file->in_h == track_height &&
                file->out_w == track_width &&
                file->out_h == track_height)
        {
            mjpeg_decompress(codec->mjpeg,
                             codec->buffer,
                             size,
                             field2_offset,
                             row_pointers,
                             row_pointers[0],
                             row_pointers[1],
                             row_pointers[2],
                             file->color_model,
                             file->cpus);
        }
        else
        {
            int i;
            unsigned char **temp_rows;
            int temp_cmodel = BC_YUV888;
            int temp_rowsize = cmodel_calculate_pixelsize(temp_cmodel) * track_width;

            if(!codec->temp_video)
                codec->temp_video = malloc(temp_rowsize * track_height);
            temp_rows = malloc(sizeof(unsigned char*) * track_height);
            for(i = 0; i < track_height; i++)
                temp_rows[i] = codec->temp_video + i * temp_rowsize;

//printf("decode 10\n");
            mjpeg_decompress(codec->mjpeg,
                             codec->buffer,
                             size,
                             field2_offset,
                             temp_rows,
                             temp_rows[0],
                             temp_rows[1],
                             temp_rows[2],
                             temp_cmodel,
                             file->cpus);

            cmodel_transfer(row_pointers,
                            temp_rows,
                            row_pointers[0],
                            row_pointers[1],
                            row_pointers[2],
                            temp_rows[0],
                            temp_rows[1],
                            temp_rows[2],
                            file->in_x,
                            file->in_y,
                            file->in_w,
                            file->in_h,
                            0,
                            0,
                            file->out_w,
                            file->out_h,
                            temp_cmodel,
                            file->color_model,
                            0,
                            track_width,
                            file->out_w);

//printf("decode 30\n");
            free(temp_rows);

//printf("decode 40\n");
        }
    }
//printf("decode 2 %d\n", result);

    return result;
}