4 * Copyright (C) 2004 Richard Baverstock
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "bcsignals.h"
26 #include "byteorder.h"
32 #include "interlacemodes.h"
35 #include "mwindow.inc"
37 #include "videodevice.inc"
38 #include "mainerror.h"
42 #include <sys/types.h>
51 FileDV::FileDV(Asset *asset, File *file)
52 : FileBase(asset, file)
64 audio_sample_buffer = 0;
65 audio_sample_buffer_len = 0;
66 audio_sample_buffer_start = 0;
67 audio_sample_buffer_end = 0;
68 audio_sample_buffer_maxsize = 0;
70 audio_frames_written = 0;
72 if(asset->format == FILE_UNKNOWN)
73 asset->format = FILE_RAWDV;
74 asset->byte_order = 0;
76 stream_lock = new Mutex("FileDV::stream_lock");
77 decoder_lock = new Mutex("FileDV::decoder_lock");
78 video_position_lock = new Mutex("FileDV::video_position_lock");
83 if(stream) close_file();
85 if(decoder) dv_decoder_free(decoder);
86 if(encoder) dv_encoder_free(encoder);
87 if(audio_encoder) dv_encoder_free(audio_encoder);
91 delete video_position_lock;
93 delete[] video_buffer;
94 delete[] audio_buffer;
96 if(audio_sample_buffer)
98 for(int i = 0; i < asset->channels; i++)
99 delete[] audio_sample_buffer[i];
100 delete[] audio_sample_buffer;
104 void FileDV::get_parameters(BC_WindowBase *parent_window,
105 Asset *asset, BC_WindowBase* &format_window,
106 int audio_options, int video_options, EDL *edl)
110 DVConfigAudio *window = new DVConfigAudio(parent_window, asset);
111 format_window = window;
112 window->create_objects();
113 window->run_window();
119 DVConfigVideo *window = new DVConfigVideo(parent_window, asset);
120 format_window = window;
121 window->create_objects();
122 window->run_window();
128 int FileDV::reset_parameters_derived()
130 if(decoder) dv_decoder_free(decoder);
131 if(encoder) dv_encoder_free(encoder);
132 if(audio_encoder) dv_encoder_free(audio_encoder);
137 TRACE("FileDV::reset_parameters_derived 10")
139 TRACE("FileDV::reset_parameters_derived: 20")
140 delete[] audio_buffer;
141 delete[] video_buffer;
142 TRACE("FileDV::reset_parameters_derived: 30")
147 if(stream) fclose(stream);
154 if(audio_sample_buffer)
156 for(int i = 0; i < asset->channels; i++)
157 delete[] audio_sample_buffer[i];
158 delete[] audio_sample_buffer;
160 audio_sample_buffer = 0;
161 audio_sample_buffer_start = 0;
162 audio_sample_buffer_len = 0;
163 audio_sample_buffer_end = 0;
164 audio_sample_buffer_maxsize = 0;
166 audio_frames_written = 0;
167 // output_size gets set in open_file, once we know if the frames are PAL or NTSC
168 // output and input are allocated at the same point.
175 int FileDV::open_file(int rd, int wr)
178 TRACE("FileDV::open_file 10")
183 TRACE("FileDV::open_file 20")
186 if (!(asset->height == 576 && asset->width == 720 && asset->frame_rate == 25) &&
187 !(asset->height == 480 && asset->width == 720 && (asset->frame_rate >= 29.96 && asset->frame_rate <= 29.98)))
189 eprintf(_("Raw DV format does not support following resolution: %ix%i framerate: %f\nAllowed resolutions are 720x576 25fps (PAL) and 720x480 29.97fps (NTSC)\n"), asset->width, asset->height, asset->frame_rate);
190 if (asset->height == 480 && asset->width == 720 && asset->frame_rate == 30)
192 eprintf(_("Suggestion: Proper frame rate for NTSC DV is 29.97 fps, not 30 fps\n"));
196 if (!(asset->channels == 2 && (asset->sample_rate == 48000 || asset->sample_rate == 44100)) &&
197 !((asset->channels == 4 || asset->channels == 2) && asset->sample_rate == 32000))
199 eprintf(_("Raw DV format does not support following audio configuration : %i channels at sample rate: %iHz\n"), asset->channels, asset->sample_rate);
204 if((stream = fopen(asset->path, "w+b")) == 0)
206 eprintf(_("Error while opening \"%s\" for writing. \n%m\n"), asset->path);
210 // Create a new encoder
211 if(encoder) dv_encoder_free(encoder);
212 encoder = dv_encoder_new(0,0,0);
213 encoder->vlc_encode_passes = 3;
214 encoder->static_qno = 0;
215 encoder->force_dct = DV_DCT_AUTO;
217 if(audio_encoder) dv_encoder_free(audio_encoder);
218 audio_encoder = dv_encoder_new(0, 0, 0);
219 audio_encoder->vlc_encode_passes = 3;
220 audio_encoder->static_qno = 0;
221 audio_encoder->force_dct = DV_DCT_AUTO;
223 if(decoder) dv_decoder_free(decoder);
224 decoder = dv_decoder_new(0,0,0);
225 decoder->quality = DV_QUALITY_BEST;
228 isPAL = (asset->height == 576 ? 1 : 0);
229 encoder->isPAL = isPAL;
230 output_size = (isPAL ? DV1394_PAL_FRAME_SIZE : DV1394_NTSC_FRAME_SIZE);
232 //printf("filedv aspect- %f \n", asset->aspect_ratio);
233 if(1.777778 - asset->aspect_ratio < 0.001f)
240 TRACE("FileDV::open_file 30")
244 TRACE("FileDV::open_file 40")
246 if((stream = fopen(asset->path, "rb")) == 0)
248 eprintf(_("Error while opening \"%s\" for reading. \n%m\n"), asset->path);
252 // temp storage to find out the correct info from the stream.
253 temp = new unsigned char[DV1394_PAL_FRAME_SIZE];
254 memset(temp, 0, DV1394_PAL_FRAME_SIZE);
256 // need file size info to get length.
257 stat(asset->path, &info);
259 TRACE("FileDV::open_file 50")
261 // read the first frame so we can get the stream info from it
262 // by reading the greatest possible frame size, we ensure we get all the
263 // data. libdv will determine if it's PAL or NTSC, and input and output
264 // buffers get allocated accordingly.
265 fread(temp, DV1394_PAL_FRAME_SIZE, 1, stream);
267 TRACE("FileDV::open_file 60")
269 if(decoder) dv_decoder_free(decoder);
270 decoder = dv_decoder_new(0,0,0);
271 decoder->quality = DV_QUALITY_BEST;
274 if(dv_parse_header(decoder, temp) > -1 )
276 // define video params first -- we need to find out output_size
278 asset->video_data = 1;
281 //TODO: according to the information I found, letterbox and widescreen
282 //are the same thing; however, libdv provides a function to check
283 //if the video feed is one of the other. Need to find out if there
285 if(dv_format_normal(decoder) != 0) asset->aspect_ratio = (double) 4 / 3;
286 else asset->aspect_ratio = (double) 16 / 9;
288 asset->width = decoder->width;
289 asset->height = decoder->height;
291 if(dv_is_progressive(decoder) > 0)
292 asset->interlace_mode = ILACE_MODE_NOTINTERLACED;
294 asset->interlace_mode = ILACE_MODE_BOTTOM_FIRST;
296 isPAL = dv_is_PAL(decoder);
298 output_size = (isPAL ? DV1394_PAL_FRAME_SIZE : DV1394_NTSC_FRAME_SIZE);
299 asset->video_length = info.st_size / output_size;
301 if(!asset->frame_rate)
302 asset->frame_rate = (isPAL ? 25 : 29.97);
303 strncpy(asset->vcodec, "dvc ", 4);
305 // see if there are any audio tracks
306 asset->channels = dv_get_num_channels(decoder);
307 if(asset->channels > 0)
309 asset->audio_data = 1;
310 asset->sample_rate = dv_get_frequency(decoder);
311 // libdv always scales the quantization up to 16 bits for dv_decode_full_audio
313 asset->audio_length = (int64_t) (info.st_size / output_size / asset->frame_rate * asset->sample_rate);
314 strncpy(asset->acodec, "dvc ", 4);
317 asset->audio_data = 0;
321 asset->audio_data = 0;
322 asset->video_data = 0;
325 fseeko(stream, 0, SEEK_SET);
326 TRACE("FileDV::open_file 80")
331 // allocate space for audio and video
332 video_buffer = new unsigned char[output_size + 4];
333 audio_buffer = new unsigned char[output_size + 4];
339 int FileDV::check_sig(Asset *asset)
341 unsigned char temp[3];
342 FILE *t_stream = fopen(asset->path, "rb");
344 fread(&temp, 3, 1, t_stream);
348 if(temp[0] == 0x1f &&
356 int FileDV::close_file_derived()
358 if(stream) fclose(stream);
364 int64_t FileDV::get_video_position()
366 return video_position;
369 int64_t FileDV::get_audio_position()
371 return audio_position;
374 int FileDV::set_video_position(int64_t x)
380 int FileDV::set_audio_position(int64_t x)
386 int FileDV::audio_samples_copy(double **buffer, int64_t len)
388 // take the buffer and copy it into a queue
389 if(!audio_sample_buffer)
391 audio_sample_buffer = new int16_t*[asset->channels];
392 if(!audio_sample_buffer)
394 fprintf(stderr, _("ERROR: Unable to allocate memory for audio_sample_buffer.\n"));
398 for(int i = 0; i < asset->channels; i++)
400 audio_sample_buffer[i] = new int16_t[len * 2];
402 if(!audio_sample_buffer[i])
404 fprintf(stderr, _("ERROR: Unable to allocate memory for "
405 "audio_sample_buffer channel %d\n"), i);
409 audio_sample_buffer_maxsize = len * 2;
410 audio_sample_buffer_len = 0;
411 audio_sample_buffer_start = 0;
412 audio_sample_buffer_end = 0;
415 if(audio_sample_buffer_maxsize <= audio_sample_buffer_len + len)
417 // Allocate double the needed size
418 for(int i = 0; i < asset->channels; i++)
420 int16_t *tmp = new int16_t[(audio_sample_buffer_len + len) * 2];
423 fprintf(stderr, _("ERROR: Unable to reallocate memory for "
424 "audio_sample_buffer channel %d\n"), i);
427 // Copy everything from audio_sample_buffer into tmp
428 for(int a = 0, b = audio_sample_buffer_start;
429 a < audio_sample_buffer_len;
430 a++, b = (b < (audio_sample_buffer_maxsize - 1) ? (b + 1) : 0))
432 tmp[a] = audio_sample_buffer[i][b];
434 // Free the current buffer, and reassign tmp to audio_sample_buffer[i]
435 delete[] audio_sample_buffer[i];
436 audio_sample_buffer[i] = tmp;
438 audio_sample_buffer_start = 0;
439 audio_sample_buffer_end = audio_sample_buffer_len - 1;
440 audio_sample_buffer_maxsize = (audio_sample_buffer_len + len) * 2;
444 for(int i = 0; i < asset->channels; i++)
446 if(len + audio_sample_buffer_end < audio_sample_buffer_maxsize)
448 // copy buffer into audio_sample_buffer, straight out (no loop around)
449 for(int a = 0; a < len; a++)
451 audio_sample_buffer[i][audio_sample_buffer_end + a] =
452 (buffer[i][a] * 32767);
454 if(i == (asset->channels - 1))
455 audio_sample_buffer_end += len;
459 // Need to loop back to the start of audio_sample_buffer
460 int copy_size = audio_sample_buffer_maxsize - audio_sample_buffer_end;
462 for(int a = 0; a < copy_size; a++)
463 audio_sample_buffer[i][a + audio_sample_buffer_end] =
464 (buffer[i][a] * 32767);
466 for(int a = 0; a < len - copy_size; a++)
467 audio_sample_buffer[i][a] = (buffer[i][a + copy_size] * 32767);
469 if(i == (asset->channels - 1))
470 audio_sample_buffer_end = len - copy_size;
474 audio_sample_buffer_len += len;
479 int FileDV::write_samples(double **buffer, int64_t len)
481 if(audio_samples_copy(buffer, len) != 0)
483 eprintf(_("Unable to store sample"));
486 video_position_lock->lock("FileDV::write_samples");
488 TRACE("FileDV::write_samples 200")
489 // Get number of frames to be written. Order of operations is important here;
490 // the buffer length must be multiplied by the frame rate first in case the
491 // number of samples in the buffer is less than the sample rate.
492 int nFrames = MIN(video_position - audio_frames_written,
493 audio_sample_buffer_len * asset->frame_rate / asset->sample_rate);
495 video_position_lock->unlock();
497 TRACE("FileDV::write_samples 220")
499 for(int i = 0; i < nFrames; i++)
501 stream_lock->lock("FileDV::write_samples 10");
502 if(fseeko(stream, (off_t) audio_frames_written * output_size, SEEK_SET) != 0)
504 eprintf(_("Unable to set audio write position to %ji\n"), (off_t) audio_frames_written * output_size);
506 stream_lock->unlock();
510 if(fread(audio_buffer, output_size, 1, stream) != 1)
512 eprintf(_("Unable to read from audio buffer file\n"));
513 stream_lock->unlock();
517 stream_lock->unlock();
521 TRACE("FileDV::write_samples 230")
523 int samples = dv_calculate_samples(audio_encoder, asset->sample_rate,
524 audio_frames_written);
526 if(samples > audio_sample_buffer_maxsize - 1 - audio_sample_buffer_start)
528 TRACE("FileDV::write_samples 210")
529 int16_t *tmp_buf[asset->channels];
530 for(int a = 0; a < asset->channels; a++)
531 tmp_buf[a] = new int16_t[asset->sample_rate];
533 TRACE("FileDV::write_samples 240")
534 int copy_size = audio_sample_buffer_maxsize - audio_sample_buffer_start - 1;
536 for(int a = 0; a < asset->channels; a++)
538 memcpy(tmp_buf[a], audio_sample_buffer[a] + audio_sample_buffer_start,
539 copy_size * sizeof(int16_t));
540 memcpy(tmp_buf[a] + copy_size, audio_sample_buffer[a],
541 (samples - copy_size) * sizeof(int16_t));
543 TRACE("FileDV::write_samples 250")
544 // Encode the audio into the frame
545 if(dv_encode_full_audio(audio_encoder, tmp_buf, asset->channels,
546 asset->sample_rate, audio_buffer) < 0)
548 eprintf(_("ERROR: unable to encode audio frame %d\n"), audio_frames_written);
550 TRACE("FileDV::write_samples 280")
552 for(int a = 0; a < asset->channels; a++)
557 TRACE("FileDV::write_samples 260")
558 int16_t **tmp_buf2 = new int16_t*[asset->channels];
559 for(int a = 0; a < asset->channels; a++)
560 tmp_buf2[a] = audio_sample_buffer[a] + audio_sample_buffer_start;
561 if(dv_encode_full_audio(audio_encoder, tmp_buf2,
562 asset->channels, asset->sample_rate, audio_buffer) < 0)
564 eprintf(_("ERROR: unable to encode audio frame %d\n"), audio_frames_written);
570 TRACE("FileDV::write_samples 270")
572 stream_lock->lock("FileDV::write_samples 20");
573 if(fseeko(stream, (off_t) audio_frames_written * output_size, SEEK_SET) != 0)
575 eprintf(_("ERROR: Unable to relocate for audio write to %ji\n"), (off_t) audio_frames_written * output_size);
576 stream_lock->unlock();
580 if(fwrite(audio_buffer, output_size, 1, stream) != 1)
582 eprintf(_("Unable to write audio to audio buffer\n"));
583 stream_lock->unlock();
587 stream_lock->unlock();
589 audio_frames_written++;
590 audio_sample_buffer_len -= samples;
591 audio_sample_buffer_start += samples;
592 if(audio_sample_buffer_start >= audio_sample_buffer_maxsize)
593 audio_sample_buffer_start -= audio_sample_buffer_maxsize;
595 TRACE("FileDV::write_samples 290")
602 int FileDV::write_frames(VFrame ***frames, int len)
605 time_t now = time(NULL);
607 if(stream == 0) return 1;
609 for(int j = 0; j < len && !result; j++)
611 VFrame *temp_frame = frames[0][j];
613 //printf("FileDV::write_frames: color_model %i\n", temp_frame->get_color_model());
614 switch(temp_frame->get_color_model())
617 memcpy(video_buffer, temp_frame->get_data(), output_size);
620 //printf("FileDV::write_frames: 4\n");
621 dv_encode_full_frame(encoder, temp_frame->get_rows(),
622 e_dv_color_yuv, video_buffer);
623 dv_encode_metadata(video_buffer, encoder->isPAL, encoder->is16x9, &now, 0);
624 dv_encode_timecode(video_buffer, encoder->isPAL, 0);
627 //printf("FileDV::write_frames: 5\n");
628 dv_encode_full_frame(encoder, temp_frame->get_rows(),
629 e_dv_color_rgb, video_buffer);
630 dv_encode_metadata(video_buffer, encoder->isPAL, encoder->is16x9, &now, 0);
631 dv_encode_timecode(video_buffer, encoder->isPAL, 0);
634 unsigned char *data = new unsigned char[asset->height * asset->width * 2];
635 unsigned char **cmodel_buf = new unsigned char *[asset->height];
636 //printf("FileDV::write_frames: 6\n");
637 unsigned char **row_pointers = temp_frame->get_rows();
638 for(int i = 0; i < asset->height; i++)
639 cmodel_buf[i] = data + asset->width * 2 * i;
641 BC_CModels::transfer(cmodel_buf, row_pointers,
642 cmodel_buf[0], cmodel_buf[1], cmodel_buf[2],
643 row_pointers[0], row_pointers[1], row_pointers[2],
644 0, 0, asset->width, asset->height,
645 0, 0, asset->width, asset->height,
646 temp_frame->get_color_model(), BC_YUV422, 0,
647 asset->width, asset->width);
649 dv_encode_full_frame(encoder, cmodel_buf,
650 e_dv_color_yuv, video_buffer);
656 //printf("FileDV::write_frames: 7\n");
658 // This is the only thread that modifies video_position,
659 // so video_position_lock can remain unlocked for reads.
660 stream_lock->lock("FileDV::write_frames");
661 if(fseeko(stream, (off_t) video_position * output_size, SEEK_SET) != 0)
663 eprintf(_("Unable to seek file to %ji\n"), (off_t)(video_position * output_size));
665 if(fwrite(video_buffer, output_size, 1, stream) < 1)
667 eprintf(_("Unable to write video data to video buffer"));
669 stream_lock->unlock();
671 video_position_lock->lock();
673 video_position_lock->unlock();
679 int FileDV::read_compressed_frame(VFrame *buffer)
682 if(stream == 0) return 0;
684 if (fseeko(stream, (off_t) video_position * output_size, SEEK_SET))
686 eprintf(_("Unable to seek file to %ji\n"), (off_t)(video_position * output_size));
688 result = fread(buffer->get_data(), output_size, 1, stream);
691 buffer->set_compressed_size(result);
696 int FileDV::write_compressed_frame(VFrame *buffer)
699 if(stream == 0) return 0;
701 if (fseeko(stream, (off_t) video_position * output_size, SEEK_SET))
703 eprintf(_("Unable to seek file to %ji\n"), (off_t)(video_position * output_size));
705 result = fwrite(buffer->get_data(), buffer->get_compressed_size(), 1, stream);
710 int64_t FileDV::compressed_frame_size()
715 int FileDV::read_samples(double *buffer, int64_t len)
719 int frame_count = get_audio_frame(audio_position);
720 int offset = get_audio_offset(audio_position);
722 stream_lock->lock("FileDV::read_samples");
725 stream_lock->unlock();
728 stream_lock->unlock();
730 // If the sample rate is 32 kHz, and the bitsize is 12, libdv
731 // requires we have space allocated for 4 channels even if
732 // the data only contains two channels.
734 // decoder will exist since it is not free'd after open_file
735 int channels = (asset->sample_rate == 32000 && decoder->audio->quantization == 12) ? 4 : 2;
737 int16_t **out_buffer = new int16_t*[channels];
738 for(int i = 0; i < channels; i++)
739 out_buffer[i] = new int16_t[DV_AUDIO_MAX_SAMPLES];
745 if(fseeko(stream, (off_t) frame_count * output_size, SEEK_SET) != 0)
747 stream_lock->unlock();
752 if(fread(audio_buffer, output_size, 1, stream) < 1)
754 stream_lock->unlock();
759 stream_lock->unlock();
763 decoder_lock->lock("FileDV::read_samples");
765 if(dv_decode_full_audio(decoder, audio_buffer, out_buffer) < 0)
767 eprintf(_("Error decoding audio frame %d\n"), frame_count - 1);
770 int end = dv_get_num_samples(decoder);
771 decoder_lock->unlock();
773 if(len - count + offset < end)
774 end = len - count + offset;
776 for(int i = offset; i < end; i++)
777 buffer[count++] = out_buffer[file->current_channel][i] / 32767.0;
782 for(int i = 0; i < channels; i++)
783 delete[] out_buffer[i];
786 audio_position += len;
791 int FileDV::read_frame(VFrame *frame)
793 if(stream == 0) return 1;
794 int pitches[3] = {720 * 2, 0, 0};
796 TRACE("FileDV::read_frame 1")
797 unsigned char **row_pointers = frame->get_rows();
800 TRACE("FileDV::read_frame 10")
802 // Seek to video position
803 stream_lock->lock("FileDV::read_frame");
804 if(fseeko(stream, (off_t) video_position * output_size, SEEK_SET) < 0)
806 eprintf(_("Unable to seek file to %ji"), (off_t)(video_position * output_size));
807 stream_lock->unlock();
810 fread(video_buffer, output_size, 1, stream);
811 stream_lock->unlock();
815 TRACE("FileDV::read_frame 20")
817 switch(frame->get_color_model())
821 TRACE("FileDV::read_frame 30")
823 frame->allocate_compressed_data(output_size);
824 frame->set_compressed_size(output_size);
825 memcpy(frame->get_data(), video_buffer, output_size);
829 TRACE("FileDV::read_frame 40")
831 pitches[0] = 720 * 3;
832 decoder_lock->lock("FileDV::read_frame 10");
833 dv_decode_full_frame(decoder, video_buffer, e_dv_color_rgb,
834 row_pointers, pitches);
835 decoder_lock->unlock();
838 TRACE("FileDV::read_frame 50")
839 decoder_lock->lock("FileDV::read_frame 20");
840 dv_decode_full_frame(decoder, video_buffer, e_dv_color_yuv,
841 row_pointers, pitches);
842 decoder_lock->unlock();
846 unsigned char *data = new unsigned char[asset->height * asset->width * 2];
847 unsigned char **temp_pointers = new unsigned char*[asset->height];
849 for(int i = 0; i < asset->height; i++)
850 temp_pointers[i] = data + asset->width * 2 * i;
853 TRACE("FileDV::read_frame 69")
855 decoder_lock->lock("FileDV::read_frame 30");
856 dv_decode_full_frame(decoder, video_buffer, e_dv_color_yuv,
857 temp_pointers, pitches);
858 decoder_lock->unlock();
860 TRACE("FileDV::read_frame 70")
862 BC_CModels::transfer(row_pointers, temp_pointers,
863 row_pointers[0], row_pointers[1], row_pointers[2],
864 temp_pointers[0], temp_pointers[1], temp_pointers[2],
865 0, 0, asset->width, asset->height,
866 0, 0, asset->width, asset->height,
867 BC_YUV422, frame->get_color_model(), 0,
868 asset->width, asset->width);
870 //for(int i = 0; i < asset->height; i++)
871 // delete[] temp_pointers[i];
872 delete[] temp_pointers;
879 TRACE("FileDV::read_frame 80")
886 int FileDV::colormodel_supported(int colormodel)
891 int FileDV::can_copy_from(Edit *edit, int64_t position)
893 if(edit->asset->format == FILE_RAWDV)
899 int FileDV::get_best_colormodel(Asset *asset, int driver)
905 case PLAYBACK_X11_XV:
907 case PLAYBACK_DV1394:
908 case PLAYBACK_FIREWIRE:
909 return BC_COMPRESSED;
911 case VIDEO4LINUX2JPEG:
913 case CAPTURE_FIREWIRE:
914 return BC_COMPRESSED;
919 int FileDV::get_audio_frame(int64_t pos)
921 return (double) pos * asset->frame_rate / asset->sample_rate;
924 // Get the sample offset from the frame start reported by get_audio_frame
925 int FileDV::get_audio_offset(int64_t pos)
927 int frame = get_audio_frame(pos);
929 // Samples needed from last frame
930 return pos - frame * asset->sample_rate / asset->frame_rate;
934 DVConfigAudio::DVConfigAudio(BC_WindowBase *parent_window, Asset *asset)
935 : BC_Window(_(PROGRAM_NAME ": Audio Compression"),
936 parent_window->get_abs_cursor_x(1),
937 parent_window->get_abs_cursor_y(1),
940 this->parent_window = parent_window;
942 // *** CONTEXT_HELP ***
943 context_help_set_keyword("Single File Rendering");
946 DVConfigAudio::~DVConfigAudio()
951 void DVConfigAudio::create_objects()
953 lock_window("DVConfigAudio::create_objects");
954 add_tool(new BC_Title(xS(10), yS(10), _("There are no audio options for this format")));
955 add_subwindow(new BC_OKButton(this));
959 int DVConfigAudio::close_event()
966 DVConfigVideo::DVConfigVideo(BC_WindowBase *parent_window, Asset *asset)
967 : BC_Window(_(PROGRAM_NAME ": Video Compression"),
968 parent_window->get_abs_cursor_x(1),
969 parent_window->get_abs_cursor_y(1),
972 this->parent_window = parent_window;
974 // *** CONTEXT_HELP ***
975 context_help_set_keyword("Single File Rendering");
978 DVConfigVideo::~DVConfigVideo()
983 void DVConfigVideo::create_objects()
985 lock_window("DVConfigVideo::create_objects");
986 add_tool(new BC_Title(xS(10), yS(10), _("There are no video options for this format")));
987 add_subwindow(new BC_OKButton(this));
991 int DVConfigVideo::close_event()