root/platform/sx400is/sub/100b/movie_rec.c

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

DEFINITIONS

This source file includes following definitions.
  1. change_video_tables
  2. set_quality
  3. save_original_bitrates
  4. modify_bitrate
  5. movie_record_task
  6. liveimage_task
  7. sub_FF915208_my
  8. sub_FF913CB4_my
  9. sub_FF913AD0_my

   1 /*
   2  * movie_rec.c - auto-generated by CHDK code_gen.
   3  */
   4 #include "conf.h"
   5 
   6 static int bitrate_multiplier = 4; // unit: factory rate / 4
   7 static int bitrate_changed = 0;
   8 extern int video_target_framesize;
   9 extern int video_target_framesize2;
  10 
  11 
  12 static int orig_bitrate[2]; // original bitrates, saved at beginning of recording
  13 
  14 void change_video_tables(int a, int b) {
  15     bitrate_multiplier = (a<<2)/b;
  16     bitrate_changed = 1;
  17 }
  18 
  19 // firmware: -12 (best) ... +20 (worst)
  20 void  set_quality(int *x){ // -17 highest; +12 lowest
  21  if (conf.video_mode) *x=12-((conf.video_quality-1)*(12+17)/(99-1));
  22 }
  23 
  24 void save_original_bitrates() {
  25     orig_bitrate[0] = video_target_framesize;
  26     orig_bitrate[1] = video_target_framesize2;
  27     bitrate_changed = 1;
  28 }
  29 
  30 void modify_bitrate() {
  31     if (bitrate_changed) {
  32         bitrate_changed = 0;
  33         video_target_framesize = (orig_bitrate[0] * bitrate_multiplier) >> 2;
  34         video_target_framesize2 = (orig_bitrate[1] * bitrate_multiplier) >> 2;
  35     }
  36 }
  37 
  38 
  39 /*************************************************************/
  40 //** movie_record_task @ 0xFF9A7E94 - 0xFF9A8024, length=101
  41 void __attribute__((naked,noinline)) movie_record_task() {
  42 asm volatile (
  43 "    STMFD   SP!, {R2-R10,LR} \n"
  44 "    LDR     R8, =0xFF9A7A94 \n"
  45 "    LDR     R4, =0x7530 \n"
  46 "    LDR     R9, =0x709 \n"
  47 "    LDR     R10, =0x2710 \n"
  48 "    MVN     R7, #0 \n"
  49 "    MOV     R5, #1 \n"
  50 "    MOV     R6, #0 \n"
  51 
  52 "loc_FF9A7EB4:\n"
  53 "    LDR     R0, [R4, #0x30] \n"
  54 "    MOV     R2, #0 \n"
  55 "    ADD     R1, SP, #4 \n"
  56 "    BL      sub_FF829E2C /*_ReceiveMessageQueue*/ \n"
  57 "    LDR     R0, [R4, #0x38] \n"
  58 "    CMP     R0, #0 \n"
  59 "    LDRNE   R0, [R4, #0x14] \n"
  60 "    CMPNE   R0, #2 \n"
  61 "    LDRNE   R0, [R4, #0x4C] \n"
  62 "    CMPNE   R0, #6 \n"
  63 "    BNE     loc_FF9A8008 \n"
  64 "    LDR     R0, [SP, #4] \n"
  65 "    LDR     R1, [R0] \n"
  66 "    SUB     R1, R1, #2 \n"
  67 "    CMP     R1, #0xD \n"
  68 "    ADDCC   PC, PC, R1, LSL#2 \n"
  69 "    B       loc_FF9A8008 \n"
  70 "    B       loc_FF9A7F7C \n"
  71 "    B       loc_FF9A7FA8 \n"
  72 "    B       loc_FF9A7FB8 \n"
  73 "    B       loc_FF9A7FC0 \n"
  74 "    B       loc_FF9A7F84 \n"
  75 "    B       loc_FF9A7FC8 \n"
  76 "    B       loc_FF9A7FF4 \n"
  77 "    B       loc_FF9A7FFC \n"
  78 "    B       loc_FF9A7F90 \n"
  79 "    B       loc_FF9A8008 \n"
  80 "    B       loc_FF9A8004 \n"
  81 "    B       loc_FF9A7F58 \n"
  82 "    B       loc_FF9A7F2C \n"
  83 
  84 "loc_FF9A7F2C:\n"
  85 "    STR     R6, [R4, #0x48] \n"
  86 "    STR     R6, [R4, #0x3C] \n"
  87 "    STR     R7, [R4, #0xD4] \n"
  88 "    STRH    R6, [R4, #8] \n"
  89 "    STR     R8, [R4, #0xB4] \n"
  90 "    LDR     R0, [R4, #0x14] \n"
  91 "    ADD     R0, R0, #1 \n"
  92 "    STR     R0, [R4, #0x14] \n"
  93 "    MOV     R0, #6 \n"
  94 "    STR     R0, [R4, #0x4C] \n"
  95 "    B       loc_FF9A7F74 \n"
  96 
  97 "loc_FF9A7F58:\n"
  98 "    STR     R6, [R4, #0x48] \n"
  99 "    STR     R7, [R4, #0xD4] \n"
 100 "    STR     R8, [R4, #0xB4] \n"
 101 "    LDR     R0, [R4, #0x14] \n"
 102 "    ADD     R0, R0, #1 \n"
 103 "    STR     R0, [R4, #0x14] \n"
 104 "    STR     R5, [R4, #0x4C] \n"
 105 
 106 "loc_FF9A7F74:\n"
 107 "    STR     R5, [R4, #0xC] \n"
 108 "    B       loc_FF9A8008 \n"
 109 
 110 "loc_FF9A7F7C:\n"
 111 "    BL      sub_FF9A777C \n"
 112 "    BL      save_original_bitrates \n"      // + (executed at recording start)
 113 "    B       loc_FF9A8008 \n"
 114 
 115 "loc_FF9A7F84:\n"
 116 "    LDR     R1, [R4, #0xB4] \n"
 117 "    BLX     R1 \n"
 118 //begin patch (only effective in VGA mode)
 119 "    LDR     R0, =video_compression_rate \n" // +
 120 "    BL      set_quality \n"                 // +
 121 "    BL      modify_bitrate \n"              // + (modifies target bitrate if requested)
 122 //end patch
 123 "    B       loc_FF9A8008 \n"
 124 
 125 "loc_FF9A7F90:\n"
 126 "    LDR     R1, [R0, #0x18] \n"
 127 "    LDR     R2, [R0, #0x28] \n"
 128 "    LDR     R3, [R0, #0x24] \n"
 129 "    LDR     R0, [R0, #4] \n"
 130 "    BL      sub_FFAFE368 \n"
 131 "    B       loc_FF9A8008 \n"
 132 
 133 "loc_FF9A7FA8:\n"
 134 "    LDR     R0, [R4, #0x4C] \n"
 135 "    CMP     R0, #5 \n"
 136 "    STRNE   R5, [R4, #0x3C] \n"
 137 "    B       loc_FF9A8008 \n"
 138 
 139 "loc_FF9A7FB8:\n"
 140 "    BL      sub_FF9A73DC \n"
 141 "    B       loc_FF9A8008 \n"
 142 
 143 "loc_FF9A7FC0:\n"
 144 "    BL      sub_FF9A729C \n"
 145 "    B       loc_FF9A8008 \n"
 146 
 147 "loc_FF9A7FC8:\n"
 148 "    LDR     R0, =0x10385C \n"
 149 "    LDR     R0, [R0, #8] \n"
 150 "    CMP     R0, #0 \n"
 151 "    LDRNE   R2, =0xFF9A71BC \n"
 152 "    LDRNE   R0, =0xFF9A7244 \n"
 153 "    MOVNE   R3, #0 \n"
 154 "    MOVNE   R1, R3 \n"
 155 "    BLNE    sub_FF86DFF4 \n"
 156 "    MOV     R0, #3 \n"
 157 "    STR     R0, [R4, #0x4C] \n"
 158 "    B       loc_FF9A8008 \n"
 159 
 160 "loc_FF9A7FF4:\n"
 161 "    BL      sub_FF9A7130 \n"
 162 "    B       loc_FF9A8008 \n"
 163 
 164 "loc_FF9A7FFC:\n"
 165 "    BL      sub_FF9A880C \n"
 166 "    B       loc_FF9A8008 \n"
 167 
 168 "loc_FF9A8004:\n"
 169 "    BL      sub_FF9A700C \n"
 170 
 171 "loc_FF9A8008:\n"
 172 "    LDR     R1, [SP, #4] \n"
 173 "    LDR     R3, =0xFF9A6CE8 /*'MovieRecorder.c'*/ \n"
 174 "    STR     R6, [R1] \n"
 175 "    STR     R9, [SP] \n"
 176 "    LDR     R0, [R4, #0x34] \n"
 177 "    MOV     R2, R10 \n"
 178 "    BL      sub_FF826770 /*_PostMessageQueueStrictly*/ \n"
 179 "    B       loc_FF9A7EB4 \n"
 180 );
 181 }
 182 
 183 /*************************************************************/
 184 //** liveimage_task @ 0xFF914F9C - 0xFF91502C, length=37
 185 void __attribute__((naked,noinline)) liveimage_task() {
 186 asm volatile (
 187 "    STMFD   SP!, {R3-R5,LR} \n"
 188 "    LDR     R4, =0x57C0 \n"
 189 
 190 "loc_FF914FA4:\n"
 191 "    MOV     R2, #0 \n"
 192 "    LDR     R0, [R4, #8] \n"
 193 "    MOV     R1, SP \n"
 194 "    BL      sub_FF829E2C /*_ReceiveMessageQueue*/ \n"
 195 "    TST     R0, #1 \n"
 196 "    BEQ     loc_FF914FD4 \n"
 197 "    MOV     R2, #0x78 \n"
 198 "    LDR     R1, =0xFF9151D4 /*'LiveImageTask.c'*/ \n"
 199 "    MOV     R0, #0 \n"
 200 "    BL      _DebugAssert \n"
 201 "    BL      _ExitTask \n"
 202 "    LDMFD   SP!, {R3-R5,PC} \n"
 203 
 204 "loc_FF914FD4:\n"
 205 "    LDR     R1, [SP] \n"
 206 "    LDR     R0, [R1] \n"
 207 "    CMP     R0, #0 \n"
 208 "    BEQ     loc_FF915008 \n"
 209 "    CMP     R0, #1 \n"
 210 "    MOVEQ   R1, #1 \n"
 211 "    BEQ     loc_FF914FFC \n"
 212 "    CMP     R0, #2 \n"
 213 "    BNE     loc_FF91501C \n"
 214 "    MOV     R1, #2 \n"
 215 
 216 "loc_FF914FFC:\n"
 217 "    LDR     R0, [R4, #0xC] \n"
 218 "    BL      sub_FF829BC0 /*_SetEventFlag*/ \n"
 219 "    B       loc_FF914FA4 \n"
 220 
 221 "loc_FF915008:\n"
 222 "    LDR     R0, [R4, #4] \n"
 223 "    CMP     R0, #1 \n"
 224 "    ADDNE   R0, R1, #4 \n"
 225 "    BLNE    sub_FF915208_my \n"  // --> Patched. Old value = 0xFF915208.
 226 "    B       loc_FF914FA4 \n"
 227 
 228 "loc_FF91501C:\n"
 229 "    MOV     R2, #0x97 \n"
 230 "    LDR     R1, =0xFF9151D4 /*'LiveImageTask.c'*/ \n"
 231 "    MOV     R0, #0 \n"
 232 "    BL      _DebugAssert \n"
 233 "    B       loc_FF914FA4 \n"
 234 );
 235 }
 236 
 237 /*************************************************************/
 238 //** sub_FF915208_my @ 0xFF915208 - 0xFF9152B0, length=43
 239 void __attribute__((naked,noinline)) sub_FF915208_my() {
 240 asm volatile (
 241 "    LDR     R1, [R0] \n"
 242 "    CMP     R1, #0x18 \n"
 243 "    ADDCC   PC, PC, R1, LSL#2 \n"
 244 "    B       loc_FF9152A4 \n"
 245 "    B       sub_FF913798 \n"
 246 "    B       sub_FF9138EC \n"
 247 "    B       loc_FF9152A4 \n"
 248 "    B       loc_FF915278 \n"
 249 "    B       sub_FF914130 \n"
 250 "    B       sub_FF91432C \n"
 251 "    B       sub_FF9146A8 \n"
 252 "    B       sub_FF913798 \n"
 253 "    B       sub_FF913F18 \n"
 254 "    B       loc_FF9152A4 \n"
 255 "    B       loc_FF9152A4 \n"
 256 "    B       loc_FF9152A4 \n"
 257 "    B       loc_FF915278 \n"
 258 "    B       sub_FF914A28 \n"
 259 "    B       sub_FF914A28 \n"
 260 "    B       loc_FF9152A4 \n"
 261 "    BX      LR \n"
 262 "    B       loc_FF9152A4 \n"
 263 "    B       loc_FF9152A4 \n"
 264 "    B       loc_FF9152A4 \n"
 265 "    B       loc_FF9152A4 \n"
 266 "    B       loc_FF9152A4 \n"
 267 "    B       loc_FF9152A4 \n"
 268 "    BX      LR \n"
 269 
 270 "loc_FF915278:\n"
 271 // HD movie codepath
 272 "    LDR     R1, [R0, #0x64] \n"
 273 "    CMP     R1, #1 \n"
 274 "    BNE     sub_FF913CB4_my \n"  // --> Patched. Old value = 0xFF913CB4.
 275 "    BEQ     sub_FF913AD0_my \n"  // --> Patched. Old value = 0xFF913AD0.
 276 
 277 "loc_FF915288:\n"
 278 "    B       sub_FF9138EC \n"
 279 
 280 "loc_FF91528C:\n"
 281 "    B       sub_FF914130 \n"
 282 
 283 "loc_FF915290:\n"
 284 "    B       sub_FF913798 \n"
 285 
 286 "loc_FF915294:\n"
 287 "    B       sub_FF91432C \n"
 288 
 289 "loc_FF915298:\n"
 290 "    B       sub_FF913F18 \n"
 291 
 292 "loc_FF91529C:\n"
 293 "    B       sub_FF9146A8 \n"
 294 
 295 "loc_FF9152A0:\n"
 296 "    B       sub_FF914A28 \n"
 297 
 298 "loc_FF9152A4:\n"
 299 "    MOV     R2, #0x69 \n"
 300 "    LDR     R1, =0xFF9151D4 /*'LiveImageTask.c'*/ \n"
 301 "    MOV     R0, #0 \n"
 302 "    B       _DebugAssert \n"
 303 );
 304 }
 305 
 306 /*************************************************************/
 307 //** sub_FF913CB4_my @ 0xFF913CB4 - 0xFF913F14, length=153
 308 void __attribute__((naked,noinline)) sub_FF913CB4_my() {
 309 asm volatile (
 310 // Need to execute our code after the firmware subroutine
 311 // it's more complicated here than usual
 312 "    PUSH    {LR} \n"                        // +
 313 "    MOV     LR, PC \n"                      // +
 314 "    LDR     PC, =0xFF913CB4 \n"  // Continue in firmware
 315 "    LDR     R0, =video_compression_rate \n" // +
 316 "    BL      set_quality \n"                 // +
 317 "    BL      modify_bitrate \n"              // + (modifies target bitrate if requested)
 318 "    POP     {PC} \n"                        // +
 319 );
 320 }
 321 
 322 /*************************************************************/
 323 //** sub_FF913AD0_my @ 0xFF913AD0 - 0xFF913CB0, length=121
 324 void __attribute__((naked,noinline)) sub_FF913AD0_my() {
 325 asm volatile (
 326 // Need to execute our code after the firmware subroutine
 327 // it's more complicated here than usual
 328 "    PUSH    {LR} \n"                        // +
 329 "    MOV     LR, PC \n"                      // +
 330 "    LDR     PC, =0xFF913AD0 \n"  // Continue in firmware
 331 "    LDR     R0, =video_compression_rate \n" // +
 332 "    BL      set_quality \n"                 // +
 333 "    BL      modify_bitrate \n"              // + (modifies target bitrate if requested)
 334 "    POP     {PC} \n"                        // +
 335 );
 336 }

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