summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Nißl <rnissl@gmx.de>2007-04-11 23:04:11 +0200
committerReinhard Nißl <rnissl@gmx.de>2007-04-11 23:04:11 +0200
commit47d88e8447b5b86f7eca03d302f2d17d2a4c9c26 (patch)
treea5fd069bea4ef744fb0f1d6174b981ecb66ceaad
parent70340520422bd57265c125c9114bf0804a0fcfb6 (diff)
downloadxine-lib-47d88e8447b5b86f7eca03d302f2d17d2a4c9c26.tar.gz
xine-lib-47d88e8447b5b86f7eca03d302f2d17d2a4c9c26.tar.bz2
Detect absence of AFD and report only changes.
The current code cannot detect the absence of AFD once it has been seen in the stream. As AFD can appear in user data after sequence, group or picture start codes, the idea is to reset the stored AFD value when processing the sequence start code. In the case where AFD is seen in user data, it is stored internally, to have it ready when the first slice is processed. At least at that time, AFD data has been seen and can be analyzed for changes. At any change, the AFD value will then be stored into a stream property. Doing this only for changes avoids locks while writing the same value over and over to the stream's property.
-rw-r--r--src/libmpeg2/decode.c25
-rw-r--r--src/libmpeg2/mpeg2.h6
2 files changed, 26 insertions, 5 deletions
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c
index 3b19feda1..3233fb9b4 100644
--- a/src/libmpeg2/decode.c
+++ b/src/libmpeg2/decode.c
@@ -87,6 +87,10 @@ void mpeg2_init (mpeg2dec_t * mpeg2dec,
mpeg2dec->code = 0xb4;
mpeg2dec->seek_mode = 0;
+ /* initialize AFD storage */
+ mpeg2dec->afd_value_seen = XINE_VIDEO_AFD_NOT_PRESENT;
+ mpeg2dec->afd_value_reported = (XINE_VIDEO_AFD_NOT_PRESENT - 1);
+
memset (mpeg2dec->picture, 0, sizeof (picture_t));
/* initialize substructures */
@@ -394,6 +398,9 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
break;
}
+ /* reset AFD value to detect absence */
+ mpeg2dec->afd_value_seen = XINE_VIDEO_AFD_NOT_PRESENT;
+
/* according to ISO/IEC 13818-2, an extension start code will follow.
* Otherwise the stream follows ISO/IEC 11172-2 which means MPEG1 */
picture->mpeg1 = (next_code != 0xb5);
@@ -469,6 +476,18 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
if (code >= 0xb0)
break;
+ /* check for AFD change once per picture */
+ if (mpeg2dec->afd_value_reported != mpeg2dec->afd_value_seen) {
+ /* AFD data should better be stored in current_frame to have it */
+ /* ready and synchronous with other data like width or height. */
+ /* An AFD change should then be detected when a new frame is emitted */
+ /* from the decoder to report the AFD change in display order and not */
+ /* in decoding order like it happens below for now. */
+ _x_stream_info_set(mpeg2dec->stream, XINE_STREAM_INFO_VIDEO_AFD, mpeg2dec->afd_value_seen);
+fprintf(stderr, "AFD changed from %d to %d\n", mpeg2dec->afd_value_reported, mpeg2dec->afd_value_seen);
+ mpeg2dec->afd_value_reported = mpeg2dec->afd_value_seen;
+ }
+
if (!(mpeg2dec->in_slice)) {
mpeg2dec->in_slice = 1;
@@ -929,9 +948,5 @@ static void process_userdata(mpeg2dec_t *mpeg2dec, uint8_t *buffer)
}
/* check Active Format Description ETSI TS 101 154 V1.5.1 */
else if (buffer[0] == 0x44 && buffer[1] == 0x54 && buffer[2] == 0x47 && buffer[3] == 0x31)
- {
- int afd = (buffer[4] & 0x40) ? (buffer[5] & 0x0f) : -1;
- _x_stream_info_set(mpeg2dec->stream, XINE_STREAM_INFO_VIDEO_AFD, afd);
-
- }
+ mpeg2dec->afd_value_seen = (buffer[4] & 0x40) ? (buffer[5] & 0x0f) : XINE_VIDEO_AFD_NOT_PRESENT;
}
diff --git a/src/libmpeg2/mpeg2.h b/src/libmpeg2/mpeg2.h
index 788fa823c..253f300a2 100644
--- a/src/libmpeg2/mpeg2.h
+++ b/src/libmpeg2/mpeg2.h
@@ -57,6 +57,12 @@ typedef struct mpeg2dec_s {
int force_aspect;
int force_pan_scan;
+ /* AFD data can be found after a sequence, group or picture start code */
+ /* and will be stored in afd_value_seen. Later it will be transfered to */
+ /* a stream property and stored into afd_value_reported to detect changes */
+ int afd_value_seen;
+ int afd_value_reported;
+
xine_stream_t *stream;
/* a spu decoder for possible closed captions */