r21619 - in trunk/stream: stream_dvdnav.c stream_dvdnav.h
Author: nicodvb Date: Fri Dec 15 00:08:09 2006 New Revision: 21619 Modified: trunk/stream/stream_dvdnav.c trunk/stream/stream_dvdnav.h Log: implemented dvdnav_lang_from_aid() to retrieve audio language Modified: trunk/stream/stream_dvdnav.c ============================================================================== --- trunk/stream/stream_dvdnav.c (original) +++ trunk/stream/stream_dvdnav.c Fri Dec 15 00:08:09 2006 @@ -515,6 +515,36 @@ return -1; } +/** + * \brief dvdnav_lang_from_aid() assigns to buf the language corresponding to audio id 'aid' + * \param stream: - stream pointer + * \param sid: physical subtitle id + * \param buf: buffer to contain the 2-chars language string + * \return 0 on error, 1 if successful + */ +int dvdnav_lang_from_aid(stream_t *stream, int aid, unsigned char *buf) { + uint8_t lg; + uint16_t lang; + dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; + + if(aid >= 0x80 && aid < 0x88) + aid -= 0x80; + else if(aid >= 0x88 && aid <= 0x8F) + aid -= 0x88; + else if(aid >= 0xA0 && aid <= 0xAF) + aid -= 0xA0; + if(aid < 0) + return 0; + lg = dvdnav_get_audio_logical_stream(priv->dvdnav, aid); + if(lg == 0xff) return 0; + lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); + if(lang == 0xffff) return 0; + buf[0] = lang >> 8; + buf[1] = lang & 0xFF; + buf[2] = 0; + return 1; +} + /** * \brief dvdnav_sid_from_lang() returns the subtitle id corresponding to the language code 'lang' Modified: trunk/stream/stream_dvdnav.h ============================================================================== --- trunk/stream/stream_dvdnav.h (original) +++ trunk/stream/stream_dvdnav.h Fri Dec 15 00:08:09 2006 @@ -31,6 +31,7 @@ int dvdnav_number_of_subs(stream_t *stream); int dvdnav_aid_from_lang(stream_t *stream, unsigned char *language); +int dvdnav_lang_from_aid(stream_t *stream, int id, unsigned char *buf); int dvdnav_sid_from_lang(stream_t *stream, unsigned char *language); int dvdnav_lang_from_sid(stream_t *stream, int sid, unsigned char *buf); int mp_dvdnav_handle_input(stream_t *stream, int cmd, int *button);
nicodvb <subversion <at> mplayerhq.hu> writes:
+ if(aid >= 0x80 && aid < 0x88) + aid -= 0x80; + else if(aid >= 0x88 && aid <= 0x8F) + aid -= 0x88; + else if(aid >= 0xA0 && aid <= 0xAF) + aid -= 0xA0; + if(aid < 0) + return 0;
or simply just aid & 0x7, the stream number for dvd's are always the lower 3 bits, other bits are flags for format. for subs its sid & 0x1f. ofcourse this is only valid for dvd's, but then again these functions is just used for dvd's. /Joakim
Joakim Plate wrote:
nicodvb <subversion <at> mplayerhq.hu> writes:
+ if(aid >= 0x80 && aid < 0x88) + aid -= 0x80; + else if(aid >= 0x88 && aid <= 0x8F) + aid -= 0x88; + else if(aid >= 0xA0 && aid <= 0xAF) + aid -= 0xA0; + if(aid < 0) + return 0;
or simply just aid & 0x7, the stream number for dvd's are always the lower 3 bits, other bits are flags for format. for subs its sid & 0x1f. ofcourse this is only valid for dvd's, but then again these functions is just used for dvd's.
/Joakim
but in this case LPCM streams should be in the range A0..A7, are they?
Nico Sabbi <nicola_sabbi <at> fastwebnet.it> writes:
but in this case LPCM streams should be in the range A0..A7, are they?
Well, i've never stumbled on any that had any outside that range. Given that dvd's by specification only allows 8 audio streams, having a larger range for one type is just odd. I'm pretty sure the spec want's to keep it simple :), oh and oh and now you will also stumble on one of the bugs in libdvdnav. dvdnav_get_audio_logical_stream actually doesn't do what it is supposed to do (acording to docs and parameter naming). it actually returns the physical stream for the given logical stream that is passed as an argument (ie the opposite) of what you want. only way around it is to fix libdvdnav or read the virtual machine yourself. you have physical, logical can be retrieved like this for(i=0;i<8;i++) { phys = (vm->state).pgc->audio_control[logical] if(phys & (1<<15)) if( (phys & 0x7) = physical ) return audioN; } /Joakim
Joakim Plate <elupus <at> ecce.se> writes:
you have physical, logical can be retrieved like this for(i=0;i<8;i++) { phys = (vm->state).pgc->audio_control[logical] if(phys & (1<<15)) if( (phys & 0x7) = physical ) return audioN; }
type.. the i, audioN and logical should of course be the same variable. /Joakim
Joakim Plate wrote:
Nico Sabbi <nicola_sabbi <at> fastwebnet.it> writes:
but in this case LPCM streams should be in the range A0..A7, are they?
Well, i've never stumbled on any that had any outside that range. Given that dvd's by specification only allows 8 audio streams, having a larger range for one type is just odd. I'm pretty sure the spec want's to keep it simple :),
ok, committed
oh and now you will also stumble on one of the bugs in libdvdnav. dvdnav_get_audio_logical_stream actually doesn't do what it is supposed to do (acording to docs and parameter naming). it actually returns the physical stream for the given logical stream that is passed as an argument (ie the opposite) of what you want. only way around it is to fix libdvdnav or read the virtual machine yourself.
you have physical, logical can be retrieved like this for(i=0;i<8;i++) { phys = (vm->state).pgc->audio_control[logical] if(phys & (1<<15)) if( (phys & 0x7) = physical ) return audioN; }
/Joakim
you should really push harder JCD to commit your patches. Thanks
participants (3)
-
Joakim Plate -
Nico Sabbi -
nicodvb