Ticket #1984: NVR_WriteVideo_cleanup2.diff
File NVR_WriteVideo_cleanup2.diff, 5.4 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/NuppelVideoRecorder.cpp
68 68 inputchannel = 1; 69 69 compression = 1; 70 70 compressaudio = 1; 71 rawmode = 0;72 71 usebttv = 1; 73 72 w = 352; 74 73 h = 240; … … 2856 2877 void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 2857 2878 bool forcekey) 2858 2879 { 2859 int tmp = 0, r = 0,out_len = OUT_LEN;2880 int tmp = 0, out_len = OUT_LEN; 2860 2881 struct rtframeheader frameheader; 2861 int xaa, freecount = 0, compressthis; 2862 int raw = 0; 2863 int timeperframe = 40; 2882 int raw = 0, compressthis = compression; 2864 2883 uint8_t *planes[3]; 2865 2884 int len = frame->size; 2866 2885 int fnum = frame->frameNumber; … … 2871 2890 2872 2891 planes[0] = buf; 2873 2892 planes[1] = planes[0] + frame->width * frame->height; 2874 if (picture_format == PIX_FMT_YUV422P) 2875 planes[2] = planes[1] + (frame->width * frame->height) / 2; 2876 else 2877 planes[2] = planes[1] + (frame->width * frame->height) / 4; 2878 compressthis = compression; 2893 planes[2] = planes[1] + (frame->width * frame->height) / 2894 (picture_format == PIX_FMT_YUV422P ? 2 : 4); 2879 2895 2880 2896 if (lf == 0) 2881 2897 { // this will be triggered every new file … … 2886 2902 forcekey = true; 2887 2903 } 2888 2904 2889 // count free buffers -- FIXME this can be done with less CPU time!!2890 for (xaa = 0; xaa < video_buffer_count; xaa++)2891 {2892 if (videobuffer[xaa]->freeToBuffer)2893 freecount++;2894 }2895 2896 if (freecount < (video_buffer_count / 3))2897 compressthis = 0; // speed up the encode process2898 2899 if (freecount < 5 || rawmode)2900 raw = 1; // speed up the encode process2901 2902 if (raw==1 || compressthis==0)2903 {2904 if (ringBuffer->IsIOBound())2905 {2906 /* need to compress, the disk can't handle any more bandwidth*/2907 raw=0;2908 compressthis=1;2909 }2910 }2911 2912 if (transcoding)2913 {2914 raw = 0;2915 compressthis = 1;2916 }2917 2918 2905 // see if it's time for a seeker header, sync information and a keyframe 2919 2906 frameheader.keyframe = frameofgop; // no keyframe defaulted 2920 2907 … … 2986 2973 } 2987 2974 else 2988 2975 { 2976 int freecount = 0; 2977 freecount = act_video_buffer > act_video_encode ? 2978 video_buffer_count - (act_video_buffer - act_video_encode) : 2979 act_video_encode - act_video_buffer; 2980 2981 if (freecount < (video_buffer_count / 3)) 2982 compressthis = 0; // speed up the encode process 2983 2984 if (freecount < 5) 2985 raw = 1; // speed up the encode process 2986 2987 if (raw==1 || compressthis==0) 2988 { 2989 if (ringBuffer->IsIOBound()) 2990 { 2991 /* need to compress, the disk can't handle any more bandwidth*/ 2992 raw=0; 2993 compressthis=1; 2994 } 2995 } 2996 2997 if (transcoding) 2998 { 2999 raw = 0; 3000 compressthis = 1; 3001 } 3002 2989 3003 if (!raw) 2990 3004 { 2991 3005 if (wantkeyframe) … … 2996 3010 tmp = len; 2997 3011 2998 3012 // here is lzo compression afterwards 2999 if (compressthis) { 3013 if (compressthis) 3014 { 3015 int r = 0; 3000 3016 if (raw) 3001 3017 r = lzo1x_1_compress((unsigned char*)buf, len, 3002 3018 out, (lzo_uint *)&out_len, wrkmem); … … 3011 3027 } 3012 3028 } 3013 3029 3014 dropped = (((fnum-lf)>>1) - 1); // should be += 0 ;-)3015 3016 if (dropped>0)3017 {3018 if (ntsc_framerate)3019 timeperframe = (int)(1000 / (30 * framerate_multiplier));3020 else3021 timeperframe = (int)(1000 / (25 * framerate_multiplier));3022 }3023 3024 // if we have lost frames we insert "copied" frames until we have the3025 // exact count because of that we should have no problems with audio3026 // sync, as long as we don't loose audio samples :-/3027 3028 while (0 && dropped > 0)3029 {3030 frameheader.timecode = lasttimecode + timeperframe;3031 lasttimecode = frameheader.timecode;3032 frameheader.keyframe = frameofgop; // no keyframe defaulted3033 frameheader.packetlength = 0; // no additional data needed3034 frameheader.frametype = 'V'; // last frame (or nullframe if first)3035 frameheader.comptype = 'L';3036 WriteFrameheader(&frameheader);3037 // we don't calculate sizes for lost frames for compression computation3038 dropped--;3039 frameofgop++;3040 }3041 3042 3030 frameheader.frametype = 'V'; // video frame 3043 3031 frameheader.timecode = timecode; 3044 3032 lasttimecode = frameheader.timecode; -
libs/libmythtv/NuppelVideoRecorder.h
138 138 139 139 int fd; // v4l input file handle 140 140 signed char *strm; 141 long dropped;142 141 unsigned int lf, tf; 143 142 int M1, M2, Q; 144 143 int w, h; … … 154 153 int audio_samplerate; // rate we request from sounddevice 155 154 int effectivedsp; // actual measured rate 156 155 157 int quiet;158 int rawmode;159 156 int usebttv; 160 157 float video_aspect; 161 158