Mercurial > mplayer.hg
changeset 32530:4157eca96947
Support reading larger blocks in one go for bd:// protocol.
author | reimar |
---|---|
date | Wed, 10 Nov 2010 17:43:48 +0000 |
parents | 0624fa95a2aa |
children | 48ee2c151251 |
files | stream/stream_bd.c |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream_bd.c Wed Nov 10 17:21:28 2010 +0000 +++ b/stream/stream_bd.c Wed Nov 10 17:43:48 2010 +0000 @@ -276,9 +276,7 @@ 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 @@ 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 @@ // 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 @@ 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;