* [devel] ffmpeg and xdtv
@ 2011-09-21 20:30 Hihin Ruslan
0 siblings, 0 replies; only message in thread
From: Hihin Ruslan @ 2011-09-21 20:30 UTC (permalink / raw)
To: devel
[-- Attachment #1.1: Type: text/plain, Size: 1884 bytes --]
Здраствуйте, наконец дошли руки до xdtv.
Разобрался почти со всеми загадками нового ffmpeg (патч
прилагаю).
Возникает одно сомнительное место, и одно место, где я не знаю
как правильно поступить.
Сомнителен для меня вот этот участок моего патча :
#if LIBAVCODEC_BUILD >= 4646
- codec_context->mb_qmin = divx.min_quantizer;
- codec_context->mb_qmax = divx.max_quantizer;
+ codec_context->qmin = divx.min_quantizer;
+ codec_context->qmax = divx.max_quantizer;
#endif
Не знаю - эквивалентна-ли замена.
А не знаю как поступить с переменной mpegts_demuxer. В старой
версии она была определена как extern и используется в
Функциях:
av_register_input_format(&mpegts_demuxer);
cur_stream = stream_open(input_filename,&mpegts_demuxer);
(обе в grab-dvb.c)
Как я понял, она используется для задания текущего (или
какого-то начального) состояния demuxer.
Сейчас она перестала быть доступной как extern. Ечсли убрать
extern, то всё собирается, но как я поенимаю, я тогда забрасываю
нули вместо этого значения. Не пойму как сделать правильно.
--
А ещё говорят так (fortune):
How sharper than a hound's tooth it is to have a thankless
serpent.
________________________________________________________________________
С уважением Хихин Руслан
[-- Attachment #1.2: xawdecode-20080708-ffmpeg.patch --]
[-- Type: text/x-diff, Size: 14987 bytes --]
diff -uNrBbwp xawdecode-20080708/src/container-ffmpeg.c xawdecode-20080708-new/src/container-ffmpeg.c
--- xawdecode-20080708/src/container-ffmpeg.c 2008-05-11 19:26:44.000000000 +0400
+++ xawdecode-20080708-new/src/container-ffmpeg.c 2011-09-21 22:40:04.090778816 +0400
@@ -47,7 +47,7 @@ extern AVCodecContext *audio_codec_conte
static int open_ofile (struct CONTAINER* This, char* filename ,int maxsize)
{
av_register_all();
- av_output_fmt = guess_format(This->shortname,NULL, NULL);
+ av_output_fmt = av_guess_format(This->shortname,NULL, NULL);
if (!av_output_fmt) {
fprintf(stderr, "Could not find suitable output format\n");
@@ -55,7 +55,7 @@ static int open_ofile (struct CONTAINER
}
/* allocate the output media context */
- oc = av_alloc_format_context();
+ oc = avformat_alloc_context();
if (!oc) {
fprintf(stderr, "Memory error\n");
return -1;
@@ -131,7 +131,7 @@ static int write_frame(struct CONTAI
av_init_packet(&pkt);
pkt.pts= av_rescale_q(video_st->codec->coded_frame->pts,video_st->codec->time_base, video_st->time_base);
if(video_st->codec->coded_frame->key_frame)
- pkt.flags |= PKT_FLAG_KEY;
+ pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index= video_st->index;
pkt.data= (uint8_t *) data;
pkt.size= bytes;
@@ -160,7 +160,7 @@ static int write_audio(struct CONTAI
av_init_packet(&pkt);
pkt.size=bytes;
pkt.pts= av_rescale_q(audio_st->codec->coded_frame->pts, audio_st->codec->time_base, audio_st->time_base);
- pkt.flags |= PKT_FLAG_KEY;
+ pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index= audio_st->index;
pkt.data= (uint8_t*) data;
diff -uNrBbwp xawdecode-20080708/src/divx.c xawdecode-20080708-new/src/divx.c
--- xawdecode-20080708/src/divx.c 2011-09-21 23:49:13.957354848 +0400
+++ xawdecode-20080708-new/src/divx.c 2011-09-21 22:30:21.267584273 +0400
@@ -442,7 +442,7 @@ static AVFrame *picture_420p = NULL;
int xdtv_to_ffmpeg(int x) {
switch(x) {
#if LIBAVCODEC_BUILD >= 4719
- case FFMPEG_XVID: return CODEC_ID_XVID;
+ case FFMPEG_XVID: return CODEC_ID_MPEG4;
#endif
case FFMPEG_MPEG4: return CODEC_ID_MPEG4;
case FFMPEG_MPEG1: return CODEC_ID_MPEG1VIDEO;
@@ -1179,7 +1179,7 @@ void divx_init(int long width, int long
// FFMpeg Parameters from MPlayer libmpcodecs/ve_lavc.c -------------------------------------
codec_context->codec_id = xdtv_to_ffmpeg(divx.codec);
- codec_context->codec_type = CODEC_TYPE_VIDEO;
+ codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
codec_context->bit_rate = divx.bitrate;
codec_context->bit_rate_tolerance = divx.bitrate*10;
codec_context->flags = 0;
@@ -1236,8 +1236,8 @@ void divx_init(int long width, int long
codec_context->debug = 0;
#endif
#if LIBAVCODEC_BUILD >= 4646
- codec_context->mb_qmin = divx.min_quantizer;
- codec_context->mb_qmax = divx.max_quantizer;
+ codec_context->qmin = divx.min_quantizer;
+ codec_context->qmax = divx.max_quantizer;
#endif
#if LIBAVCODEC_BUILD >= 4647
codec_context->me_cmp = ffmpeg.cmp;
@@ -2003,7 +2003,7 @@ codec_context->mv0_threshold
if (audio_codec_context == NULL)
audio_codec_context = avcodec_alloc_context();
audio_codec_context->codec_id = xdtv_to_audioffmpeg(divx.audio_codec);
- audio_codec_context->codec_type= CODEC_TYPE_AUDIO;
+ audio_codec_context->codec_type= AVMEDIA_TYPE_AUDIO;
switch(divx.audio_codec) {
// we force to the maximum bitrate as it's not possible to configure it through the GUI
case FFMPEG_AMR_NB: audio_codec_context->bit_rate = 12200; break;
diff -uNrBbwp xawdecode-20080708/src/grab-dvb.c xawdecode-20080708-new/src/grab-dvb.c
--- xawdecode-20080708/src/grab-dvb.c 2011-09-21 23:49:13.965354474 +0400
+++ xawdecode-20080708-new/src/grab-dvb.c 2011-09-21 23:47:45.925474827 +0400
@@ -81,7 +81,6 @@ extern int use_file_audio;
extern int filenoaudioout;
extern void video_set_capture_size(int w, int h);
//extern int nbufs;
-extern AVInputFormat mpegts_demuxer;
extern AVCodec mpeg2video_decoder;
extern AVCodec mp2_decoder;
extern char* avifilename;
@@ -90,6 +89,11 @@ int frameFinished;
int dvb_grabber_running=0;
static int stream_opened=0;
+AVInputFormat mpegts_demuxer;
+
+
+
+
/**** Video **/
static AVFrame *pFrameRGB;
static int numBytesRGB;
@@ -933,9 +937,9 @@ static int video_thread(void *arg)
/* NOTE: ipts is the PTS of the _first_ picture beginning in
this packet, if any */
global_video_pkt_pts= pkt->pts;
- len1 = avcodec_decode_video(is->video_st->codec,
+ len1 = avcodec_decode_video2(is->video_st->codec,
frame, &got_picture,
- pkt->data, pkt->size);
+ pkt);
if( (/*decoder_reorder_pts || // XDTV dfunction doesn't exist*/ pkt->dts == AV_NOPTS_VALUE)
&& frame->opaque && *(uint64_t*)frame->opaque != AV_NOPTS_VALUE)
@@ -1052,9 +1056,9 @@ static int audio_decode_frame(VideoState
/* NOTE: the audio packet can contain several frames */
while (is->audio_pkt_size > 0) {
data_size = buf_size;
- len1 = avcodec_decode_audio2(is->audio_st->codec,
+ len1 = avcodec_decode_audio3(is->audio_st->codec,
(int16_t *)audio_buf, &data_size,
- is->audio_pkt_data, is->audio_pkt_size);
+ &is->audio_pkt);
if (len1 < 0) {
/* if error, we skip the frame */
is->audio_pkt_size = 0;
@@ -1186,7 +1190,7 @@ static int stream_component_open(VideoSt
enc = ic->streams[stream_index]->codec;
/* prepare audio output */
- if (enc->codec_type == CODEC_TYPE_AUDIO) {
+ if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
if (enc->channels > 0) {
enc->request_channels = FFMIN(2, enc->channels);
} else {
@@ -1212,7 +1216,7 @@ static int stream_component_open(VideoSt
return -1;
/* prepare audio output */
- if (enc->codec_type == CODEC_TYPE_AUDIO) {
+ if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
wanted_spec.freq = enc->sample_rate;
wanted_spec.format = AUDIO_S16SYS;
wanted_spec.channels = enc->channels;
@@ -1231,7 +1235,7 @@ static int stream_component_open(VideoSt
avcodec_thread_init(enc, thread_count);
enc->thread_count= thread_count;
switch(enc->codec_type) {
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
is->audio_stream = stream_index;
is->audio_st = ic->streams[stream_index];
is->audio_buf_size = 0;
@@ -1248,7 +1252,7 @@ static int stream_component_open(VideoSt
packet_queue_init(&is->audioq);
SDL_PauseAudio(0);
break;
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
is->video_stream = stream_index;
is->video_st = ic->streams[stream_index];
@@ -1262,7 +1266,7 @@ static int stream_component_open(VideoSt
enc-> get_buffer= my_get_buffer;
enc->release_buffer= my_release_buffer;
break;
- case CODEC_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_SUBTITLE:
is->subtitle_stream = stream_index;
is->subtitle_st = ic->streams[stream_index];
packet_queue_init(&is->subtitleq);
@@ -1286,14 +1290,14 @@ static void stream_component_close(Video
enc = ic->streams[stream_index]->codec;
switch(enc->codec_type) {
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
packet_queue_abort(&is->audioq);
SDL_CloseAudio();
packet_queue_end(&is->audioq);
break;
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
packet_queue_abort(&is->videoq);
/* note: we also signal this mutex to make sure we deblock the
@@ -1306,7 +1310,7 @@ static void stream_component_close(Video
packet_queue_end(&is->videoq);
break;
- case CODEC_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_SUBTITLE:
packet_queue_abort(&is->subtitleq);
/* note: we also signal this mutex to make sure we deblock the
@@ -1327,15 +1331,15 @@ static void stream_component_close(Video
avcodec_close(enc);
switch(enc->codec_type) {
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
is->audio_st = NULL;
is->audio_stream = -1;
break;
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
is->video_st = NULL;
is->video_stream = -1;
break;
- case CODEC_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_SUBTITLE:
is->subtitle_st = NULL;
is->subtitle_stream = -1;
break;
@@ -1347,22 +1351,29 @@ static void stream_component_close(Video
// SYNCH Rev. 1137
static void dump_stream_info(const AVFormatContext *s)
{
- if (s->track != 0)
- fprintf(stderr, "Track: %d\n", s->track);
- if (s->title[0] != '\0')
- fprintf(stderr, "Title: %s\n", s->title);
- if (s->author[0] != '\0')
- fprintf(stderr, "Author: %s\n", s->author);
- if (s->copyright[0] != '\0')
- fprintf(stderr, "Copyright: %s\n", s->copyright);
- if (s->comment[0] != '\0')
- fprintf(stderr, "Comment: %s\n", s->comment);
- if (s->album[0] != '\0')
- fprintf(stderr, "Album: %s\n", s->album);
- if (s->year != 0)
- fprintf(stderr, "Year: %d\n", s->year);
- if (s->genre[0] != '\0')
- fprintf(stderr, "Genre: %s\n", s->genre);
+AVDictionaryEntry *meta;
+
+// meta=av_dict_get(s->metadata, "track", NULL, 0);
+// fprintf(stderr, "Track: %s\n", meta->value);
+
+
+
+ meta=av_dict_get(s->metadata, "track", NULL, 0);
+ fprintf(stderr, "Track: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "title", NULL, 0);
+ fprintf(stderr, "Title: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "author", NULL, 0);
+ fprintf(stderr, "Author: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "copyright", NULL, 0);
+ fprintf(stderr, "Copyright: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "comment", NULL, 0);
+ fprintf(stderr, "Comment: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "album", NULL, 0);
+ fprintf(stderr, "Album: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "year", NULL, 0);
+ fprintf(stderr, "Year: %s\n", meta->value);
+ meta=av_dict_get(s->metadata, "genre", NULL, 0);
+ fprintf(stderr, "Genre: %s\n", meta->value);
}
/* since we have only one decoding thread, we can use a global
@@ -1442,11 +1453,11 @@ static int decode_thread(void *arg)
for(i = 0; i < ic->nb_streams; i++) {
AVCodecContext *enc = ic->streams[i]->codec;
switch(enc->codec_type) {
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
if ((audio_index < 0 || wanted_audio_stream-- > 0) && !audio_disable)
audio_index = i;
break;
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
if ((video_index < 0 || wanted_video_stream-- > 0) && !video_disable)
video_index = i;
break;
@@ -1665,19 +1676,19 @@ static void stream_cycle_channel(VideoSt
int start_index, stream_index;
AVStream *st;
- if (codec_type == CODEC_TYPE_VIDEO)
+ if (codec_type == AVMEDIA_TYPE_VIDEO)
start_index = is->video_stream;
- else if (codec_type == CODEC_TYPE_AUDIO)
+ else if (codec_type == AVMEDIA_TYPE_AUDIO)
start_index = is->audio_stream;
else
start_index = is->subtitle_stream;
- if (start_index < (codec_type == CODEC_TYPE_SUBTITLE ? -1 : 0))
+ if (start_index < (codec_type == AVMEDIA_TYPE_SUBTITLE ? -1 : 0))
return;
stream_index = start_index;
for(;;) {
if (++stream_index >= is->ic->nb_streams)
{
- if (codec_type == CODEC_TYPE_SUBTITLE)
+ if (codec_type == AVMEDIA_TYPE_SUBTITLE)
{
stream_index = -1;
goto the_end;
@@ -1690,13 +1701,13 @@ static void stream_cycle_channel(VideoSt
if (st->codec->codec_type == codec_type) {
/* check that parameters are OK */
switch(codec_type) {
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
if (st->codec->sample_rate != 0 &&
st->codec->channels != 0)
goto the_end;
break;
- case CODEC_TYPE_VIDEO:
- case CODEC_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_VIDEO:
+ case AVMEDIA_TYPE_SUBTITLE:
goto the_end;
default:
break;
@@ -1747,15 +1758,15 @@ static void event_loop(void)
break;
case SDLK_a:
if (cur_stream)
- stream_cycle_channel(cur_stream, CODEC_TYPE_AUDIO);
+ stream_cycle_channel(cur_stream, AVMEDIA_TYPE_AUDIO);
break;
case SDLK_v:
if (cur_stream)
- stream_cycle_channel(cur_stream, CODEC_TYPE_VIDEO);
+ stream_cycle_channel(cur_stream, AVMEDIA_TYPE_VIDEO);
break;
case SDLK_t:
if (cur_stream)
- stream_cycle_channel(cur_stream, CODEC_TYPE_SUBTITLE);
+ stream_cycle_channel(cur_stream, AVMEDIA_TYPE_SUBTITLE);
break;
case SDLK_w:
//toggle_audio_display(); // XDTV
diff -uNrBbwp xawdecode-20080708/src/grab-v4l2.c xawdecode-20080708-new/src/grab-v4l2.c
--- xawdecode-20080708/src/grab-v4l2.c 2011-09-21 23:49:13.969354286 +0400
+++ xawdecode-20080708-new/src/grab-v4l2.c 2011-09-21 22:30:21.271584048 +0400
@@ -43,7 +43,7 @@
#include "grab.h"
#include "channel.h"
#ifdef HAVE_V4L_2
-#include <linux/videodev.h>
+//#include <linux/videodev.h>
#include <linux/videodev2.h>
#include "colorspace.h"
#include "memcpy.h"
diff -uNrBbwp xawdecode-20080708/src/main.c xawdecode-20080708-new/src/main.c
--- xawdecode-20080708/src/main.c 2011-09-21 23:49:13.969354286 +0400
+++ xawdecode-20080708-new/src/main.c 2011-09-21 22:30:21.271584048 +0400
@@ -105,7 +105,6 @@
#include "devicemanager/devicemanager_ui.h"
#ifdef HAVE_V4L_2
-#include <linux/videodev.h>
#include <linux/videodev2.h>
#endif
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-21 20:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21 20:30 [devel] ffmpeg and xdtv Hihin Ruslan
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git