smem doesn't work with vcodec=I420
Posted: 06 Mar 2011 18:49
I'm testing some idea with smem, and noticed a weired thing.
See the next code.
I tested this code in my MacBook Pro(OSX Snow Leopard).
The above code prints out ""video-prerender-callback function works." in some lines.
However, when I changed the vcodec=I444 to vcodec=I420, it does not output my debugging message in the callback function 'cbVideoPrerender'.
I checked the debugging message from vlc with verbose option, but there's no notable error.
AFAIK, both of I444 and I420 are raw video format. and smem should work with them.
Why is not the callback function called with I420, and how can I make it work?
FYI, I checked the source code of smem.c, and I found likeso, I think I420 is definitely compitible format.
See the next code.
Code: Select all
#include <vlc/vlc.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
typedef unsigned int uint;
void cbVideoPrerender(void *p_video_data, uint8_t **pp_pixel_buffer, int size) {
printf("video-prerender-callback function works.\n");
fflush(stdout);
// Locking
*pp_pixel_buffer = (uint8_t*)malloc(size);
}
void cbVideoPostrender(void *p_video_data, uint8_t *p_pixel_buffer
, int width, int height, int pixel_pitch, int size, int64_t pts) {
// Unlocking
}
void cbAudioPrerender(void *p_audio_data, uint8_t** pp_pcm_buffer , uint size) {
// Locking
*pp_pcm_buffer = (uint8_t*)malloc(size);
}
void cbAudioPostrender(void* p_audio_data, uint8_t* p_pcm_buffer
, uint channels, uint rate, uint nb_samples, uint bits_per_sample, uint size, int64_t pts) {
// Unlocking
}
int main(int argc, char **argv) {
if (argc < 2) {
printf("Usage: test-smem <file>\n");
return -1;
}
char smem_options[1000];
sprintf(smem_options
, "#transcode{vcodec=I444,acodec=s16l}:smem{"
"video-prerender-callback=%lld,"
"video-postrender-callback=%lld,"
"audio-prerender-callback=%lld,"
"audio-postrender-callback=%lld},"
, (long long int)(intptr_t)(void*)&cbVideoPrerender
, (long long int)(intptr_t)(void*)&cbVideoPostrender
, (long long int)(intptr_t)(void*)&cbAudioPrerender
, (long long int)(intptr_t)(void*)&cbAudioPostrender);
const char *const vlc_args[] = {
"-I", "dummy",
"--ignore-config",
"--extraintf=logger",
"--verbose=2",
"--sout", smem_options // Stream to memory
};
libvlc_instance_t *vlc = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
libvlc_media_player_t *mp = libvlc_media_player_new(vlc);
libvlc_media_t *m = libvlc_media_new_path(vlc, argv[1]);
libvlc_media_player_set_media(mp, m);
libvlc_media_release(m);
libvlc_media_player_play(mp);
sleep(5);
libvlc_media_player_stop (mp);
libvlc_media_player_release (mp);
libvlc_release (vlc);
return 0;
}
The above code prints out ""video-prerender-callback function works." in some lines.
However, when I changed the vcodec=I444 to vcodec=I420, it does not output my debugging message in the callback function 'cbVideoPrerender'.
I checked the debugging message from vlc with verbose option, but there's no notable error.
AFAIK, both of I444 and I420 are raw video format. and smem should work with them.
Why is not the callback function called with I420, and how can I make it work?
FYI, I checked the source code of smem.c, and I found like
Code: Select all
switch( p_fmt->i_codec )
{
case VLC_CODEC_RGB32:
case VLC_CODEC_RGBA:
i_bits_per_pixel = 32;
break;
case VLC_CODEC_I444:
case VLC_CODEC_RGB24:
i_bits_per_pixel = 24;
break;
case VLC_CODEC_RGB16:
case VLC_CODEC_RGB15:
case VLC_CODEC_RGB8:
case VLC_CODEC_I422:
i_bits_per_pixel = 16;
break;
case VLC_CODEC_YV12:
case VLC_CODEC_I420:
i_bits_per_pixel = 12;
break;
case VLC_CODEC_RGBP:
i_bits_per_pixel = 8;
break;
default:
msg_Err( p_stream, "Smem does only support raw video format" );
return NULL;
}