raspi: first implementation of PIG in AVDec

This commit is contained in:
Stefan Seyfried
2013-10-21 00:08:47 +02:00
parent 824c602fb6
commit e0f5184900
4 changed files with 44 additions and 8 deletions

View File

@@ -36,6 +36,10 @@
#include "avcodec_omx.h" #include "avcodec_omx.h"
#include "omx_utils.h" #include "omx_utils.h"
#include "bcm_host.h"
/* set in glfb.cpp */
extern DISPMANX_MODEINFO_T output_info;
static void* acodec_omx_thread(struct codec_init_args_t* args) static void* acodec_omx_thread(struct codec_init_args_t* args)
{ {
struct codec_t* codec = args->codec; struct codec_t* codec = args->codec;
@@ -243,14 +247,19 @@ next_packet:
omx_set_display_region(pi, 0, 0, 1920, 1080); omx_set_display_region(pi, 0, 0, 1920, 1080);
current = NULL; current = NULL;
goto next_packet; goto next_packet;
} else if (current->msgtype == MSG_ZOOM) { } else if (current->msgtype == MSG_PIG) {
if ((int)current->data) { struct pig_params_t *pig = (struct pig_params_t *)current->data;
fprintf(stderr,"4:3 on!\n"); if (pig->x < 0)
omx_set_display_region(pi, 240, 0, 1440, 1080); omx_set_display_region(pi, 0, 0, output_info.width, output_info.height);
} else { else {
fprintf(stderr,"4:3 off\n"); int x = pig->x * output_info.width / 1280;
omx_set_display_region(pi, 0, 0, 1920, 1080); int y = pig->y * output_info.height / 720;
int w = pig->w * output_info.width / 1280;
int h = pig->h * output_info.height / 720;
omx_set_display_region(pi, x, y, w, h);
} }
free(pig);
free(current);
current = NULL; current = NULL;
goto next_packet; goto next_packet;
} }

View File

@@ -99,6 +99,7 @@ class vDec: public Dec, public OpenThreads::Thread
public: public:
vDec(); vDec();
~vDec(); ~vDec();
int set_pig(int x, int y, int w, int h);
private: private:
void run(); void run();
}; };
@@ -253,6 +254,13 @@ int AVDec::set_volume(int vol)
return -1; return -1;
} }
int AVDec::pig(int x, int y, int w, int h)
{
if (vdec)
return vdec->set_pig(x, y, w, h);
return -1;
}
typedef struct { typedef struct {
Dec *d; Dec *d;
bool audio; bool audio;
@@ -415,6 +423,17 @@ int aDec::set_volume(int vol)
return 0; return 0;
} }
int vDec::set_pig(int x, int y, int w, int h)
{
struct pig_params_t *pig = (pig_params_t *)malloc(sizeof(struct pig_params_t));
pig->x = x;
pig->y = y;
pig->w = w;
pig->h = h;
codec_send_message(&codecs.vcodec, MSG_PIG, pig);
return 0;
}
void vDec::run() void vDec::run()
{ {
hal_set_threadname("hal:vdec"); hal_set_threadname("hal:vdec");

View File

@@ -29,7 +29,7 @@ struct packet_t
#define MSG_STOP 3 #define MSG_STOP 3
#define MSG_PAUSE 4 #define MSG_PAUSE 4
#define MSG_NEW_CHANNEL 5 #define MSG_NEW_CHANNEL 5
#define MSG_ZOOM 6 #define MSG_PIG 6
#define MSG_SET_ASPECT_4_3 7 #define MSG_SET_ASPECT_4_3 7
#define MSG_SET_ASPECT_16_9 8 #define MSG_SET_ASPECT_16_9 8
#define MSG_SET_VOLUME 9 #define MSG_SET_VOLUME 9
@@ -64,6 +64,13 @@ struct codec_t
int first_packet; int first_packet;
}; };
struct pig_params_t{
int x;
int y;
int w;
int h;
};
struct codecs_t { struct codecs_t {
pthread_mutex_t playback_mutex; /* Locked by the thread with access to playback - htsp/avplay/etc */ pthread_mutex_t playback_mutex; /* Locked by the thread with access to playback - htsp/avplay/etc */

View File

@@ -158,6 +158,7 @@ void cVideo::Pig(int x, int y, int w, int h, int, int)
pig_y = y; pig_y = y;
pig_w = w; pig_w = w;
pig_h = h; pig_h = h;
avdec->pig(x, y, w, h);
} }
void cVideo::getPictureInfo(int &width, int &height, int &rate) void cVideo::getPictureInfo(int &width, int &height, int &rate)