Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bdde570

Browse files
committedJan 24, 2016
firmware/lm32/encoder: fix fps limitation and add encoder fps command
1 parent e1729c0 commit bdde570

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed
 

‎firmware/lm32/ci.c

+8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static void help_encoder(void)
7171
puts("encoder on - enable encoder");
7272
puts("encoder off - disable encoder");
7373
puts("encoder quality <quality> - select quality");
74+
puts("encoder fps <fps> - configure target fps");
7475
}
7576
#endif
7677

@@ -375,6 +376,11 @@ static void encoder_configure_quality(int quality)
375376
encoder_set_quality(quality);
376377
}
377378

379+
static void encoder_configure_fps(int fps)
380+
{
381+
printf("Setting encoder fps to %d\r\n", fps);
382+
encoder_set_fps(fps);
383+
}
378384

379385
static void encoder_off(void)
380386
{
@@ -593,6 +599,8 @@ void ci_service(void)
593599
encoder_off();
594600
else if(strcmp(token, "quality") == 0)
595601
encoder_configure_quality(atoi(get_token(&str)));
602+
else if(strcmp(token, "fps") == 0)
603+
encoder_configure_fps(atoi(get_token(&str)));
596604
else
597605
help_encoder();
598606
}

‎firmware/lm32/encoder.c

+17-3
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,35 @@ int encoder_set_quality(int quality) {
160160
return 1;
161161
}
162162

163+
int encoder_set_fps(int fps) {
164+
if(encoder_target_fps > 0 && encoder_target_fps <= 60) {
165+
encoder_target_fps = fps;
166+
return 0;
167+
}
168+
else {
169+
encoder_target_fps = 30;
170+
return 1;
171+
}
172+
}
173+
163174
void encoder_service(void) {
164175

165176
static int last_event;
166177
static int last_fps_event;
167178
static int frame_cnt;
179+
static int can_start;
168180

169181
if(encoder_enabled) {
170-
if(elapsed(&last_event, identifier_frequency_read()/30)) {
171-
if (encoder_done() == 1) {
182+
if(elapsed(&last_event, identifier_frequency_read()/encoder_target_fps)) {
183+
can_start = 1;
184+
}
185+
if(can_start & encoder_done()) {
172186
encoder_init(encoder_quality);
173187
encoder_start(processor_h_active, processor_v_active);
174188
encoder_reader_dma_length_write(processor_h_active*processor_v_active*2);
175189
encoder_reader_dma_shoot_write(1);
176190
frame_cnt++;
177-
}
191+
}
178192
}
179193
if(elapsed(&last_fps_event, identifier_frequency_read())) {
180194
encoder_fps = frame_cnt;

‎firmware/lm32/encoder.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const char chroma_rom_75[64];
2323
const char chroma_rom_50[64];
2424

2525
char encoder_enabled;
26+
int encoder_target_fps;
2627
int encoder_fps;
2728
int encoder_quality;
2829

@@ -33,6 +34,7 @@ void encoder_start(short resx, short resy);
3334
int encoder_done(void);
3435
void encoder_enable(char enable);
3536
int encoder_set_quality(int quality);
37+
int encoder_set_fps(int fps);
3638
void encoder_service(void);
3739

3840
#endif

‎firmware/lm32/processor.c

+1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ void processor_init(void)
371371
processor_encoder_source = VIDEO_IN_HDMI_IN0;
372372
#ifdef ENCODER_BASE
373373
encoder_enable(0);
374+
encoder_target_fps = 30;
374375
#endif
375376
}
376377

0 commit comments

Comments
 (0)
Please sign in to comment.