root/platform/generic/movie_rec.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. change_video_tables
  2. change_video_minbitrate
  3. get_video_recorded_size_kb
  4. set_quality
  5. set_movie_time_limit
  6. bitrate_calc

   1 #include "platform.h"
   2 
   3 #ifdef CAM_MOVIEREC_NEWSTYLE
   4 
   5 #include "conf.h"
   6 #include "clock.h"
   7 
   8 static int bitrate_multi_a, bitrate_multi_b;
   9 static int mbitrate_multi_a, mbitrate_multi_b;
  10 static unsigned int recorded_kb;
  11 
  12 /*
  13  * functions called from core
  14  */
  15 
  16 void change_video_tables(int a, int b) {
  17     bitrate_multi_a = a;
  18     bitrate_multi_b = b;
  19 }
  20 void change_video_minbitrate(int a, int b) {
  21     mbitrate_multi_a = a;
  22     mbitrate_multi_b = b;
  23 }
  24 unsigned int get_video_recorded_size_kb() {
  25     return recorded_kb;
  26 }
  27 
  28 /*
  29  * functions called from platform
  30  */
  31 
  32 // as of writing, factory bitrates are set to approx. cbr;
  33 // in all known cases, high-mid and mid-low is '100'
  34 // that is the source of the magic value below
  35 void  set_quality(int *struc){ // struc: addr of fw struct on stack
  36     int low = *(struc+BR_LOW_OFS/4);
  37     int mid = *(struc+BR_MID_OFS/4);
  38     int hgh = *(struc+BR_HI_OFS/4);
  39     if (conf.video_mode == 1) { // CBR mode
  40         hgh = hgh * bitrate_multi_a / bitrate_multi_b;
  41         if (hgh > MAX_VIDEO_BITRATE) hgh = MAX_VIDEO_BITRATE;
  42         mid = (hgh > 400) ? hgh-100 : hgh-(hgh>>2);
  43         low = (mid > 400) ? mid-100 : mid-(mid>>2);
  44     }
  45     else if (conf.video_mode == 2) { // VBR HI mode
  46         hgh = hgh * bitrate_multi_a / bitrate_multi_b;
  47         if (hgh > MAX_VIDEO_BITRATE) hgh = MAX_VIDEO_BITRATE;
  48         low = hgh * mbitrate_multi_a / mbitrate_multi_b;
  49         mid = (hgh-low > 400) ? hgh-100 : hgh-((hgh-low)>>2);
  50     }
  51     else if (conf.video_mode == 3) { // VBR MID mode
  52         hgh = hgh * bitrate_multi_a / bitrate_multi_b;
  53         if (hgh > MAX_VIDEO_BITRATE) hgh = MAX_VIDEO_BITRATE;
  54         low = hgh * mbitrate_multi_a / mbitrate_multi_b;
  55         mid = (hgh + low) / 2;
  56     }
  57     else if (conf.video_mode == 4) { // VBR LOW mode
  58         hgh = hgh * bitrate_multi_a / bitrate_multi_b;
  59         if (hgh > MAX_VIDEO_BITRATE) hgh = MAX_VIDEO_BITRATE;
  60         low = hgh * mbitrate_multi_a / mbitrate_multi_b;
  61         mid = (hgh-low > 400) ? low+100 : low+((hgh-low)>>2);
  62     }
  63     if ((hgh>0) && (mid>0) && (low>0)) {
  64         *(struc+BR_LOW_OFS/4) = low;
  65         *(struc+BR_MID_OFS/4) = mid;
  66         *(struc+BR_HI_OFS/4) = hgh;
  67     }
  68     // we're at start of a recording, init movie data variables
  69     recorded_kb = 0;
  70 }
  71 
  72 int set_movie_time_limit(int limit) {
  73     // 
  74     if ((conf.ext_video_time == 1) && (limit <= FW_SHORT_TIME_LIMIT)) {
  75         // limits below threshold need user permission
  76         return SHORT_TIME_LIMIT;
  77     }
  78     // all other movie kinds get the higher limit
  79     return LONG_TIME_LIMIT;
  80 }
  81 
  82 void bitrate_calc(unsigned int sum) {
  83     recorded_kb += sum / 1024;
  84 }
  85 

/* [<][>][^][v][top][bottom][index][help] */