[MPlayer-cvslog] r32617 - trunk/stream/stream_bd.c
reimar
subversion at mplayerhq.hu
Wed Nov 10 18:43:48 CET 2010
Author: reimar
Date: Wed Nov 10 18:43:48 2010
New Revision: 32617
Log:
Support reading larger blocks in one go for bd:// protocol.
Modified:
trunk/stream/stream_bd.c
Modified: trunk/stream/stream_bd.c
==============================================================================
--- trunk/stream/stream_bd.c Wed Nov 10 18:21:28 2010 (r32616)
+++ trunk/stream/stream_bd.c Wed Nov 10 18:43:48 2010 (r32617)
@@ -276,9 +276,7 @@ static int bd_get_uks(struct bd_priv *bd
static off_t bd_read(struct bd_priv *bd, uint8_t *buf, int len)
{
int read_len;
- // TODO: would be nicer if this function also worked for larger reads
- int max_len = BD_UNIT_SIZE - (bd->pos % BD_UNIT_SIZE);
- len = FFMIN(len, max_len);
+ int unit_offset = bd->pos % BD_UNIT_SIZE;
len &= ~15;
if (!len)
return 0;
@@ -287,10 +285,14 @@ static off_t bd_read(struct bd_priv *bd,
if (read_len != len)
return -1;
- if (bd->pos % BD_UNIT_SIZE) {
- // decrypt in place
- av_aes_crypt(bd->aescbc, buf, buf, len / 16, bd->iv.u8, 1);
- } else {
+ if (unit_offset) {
+ int decrypt_len = BD_UNIT_SIZE - unit_offset;
+ av_aes_crypt(bd->aescbc, buf, buf, decrypt_len / 16, bd->iv.u8, 1);
+ buf += decrypt_len;
+ len -= decrypt_len;
+ }
+ while (len) {
+ int decrypt_len = FFMIN(len, BD_UNIT_SIZE);
// reset aes context as at start of unit
key enc_seed;
bd->iv = BD_CBC_IV;
@@ -307,7 +309,9 @@ static off_t bd_read(struct bd_priv *bd,
// decrypt
av_aes_crypt(bd->aescbc, &buf[16], &buf[16],
- (len - 16) / 16, bd->iv.u8, 1);
+ (decrypt_len - 16) / 16, bd->iv.u8, 1);
+ buf += decrypt_len;
+ len -= decrypt_len;
}
bd->pos += read_len;
@@ -461,6 +465,7 @@ static int bd_stream_open(stream_t *s, i
bd->device = DEFAULT_BD_DEVICE;
s->sector_size = BD_UNIT_SIZE;
+ s->read_chunk = 32 * BD_UNIT_SIZE;
s->flags = STREAM_READ | MP_STREAM_SEEK;
s->fill_buffer = bd_stream_fill_buffer;
s->seek = bd_stream_seek;
More information about the MPlayer-cvslog
mailing list