On Thu, Mar 18, 2010 at 05:42:13AM +0530, Mohamed Naufal wrote:
On 18 March 2010 05:01, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
+ + ? ? ? ?yop_get_next_nibble(s, ¤t_byte); +
+ ? ? ? ?if ((current_byte & 0xf0) != 0xf0) { + ? ? ? ? ? ?yop_paint_block(s, current_byte >> 4); + ? ? ? ?}else { + ? ? ? ? ? ?yop_get_next_nibble(s, ¤t_byte); + ? ? ? ? ? ?yop_copy_previous_block(s, current_byte >> 4); + ? ? ? ?}
extracting the top 4bits is done several times
I can't think of any other way to eliminate the current_tag_byte variable in the previous patch :(
something like: yop_get_next_nibble(){ if(low_nibble){ ret= *low_nibble & 0xF; low_nibble=NULL; }else{ low_nibble=p; ret= *p++>>4; } return ret; } might work, not really pretty either
[...]
+static int yop_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + ? ?YopDecContext *yop = s->priv_data; + ? ?ByteIOContext *pb ?= s->pb; + + ? ?int ret; + ? ?int palette_size ? ? ? ? ? = 4 + yop->num_pal_colors * 3; + ? ?int actual_video_data_size = yop->frame_size - + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? yop->audio_block_length - palette_size; + + ? ?yop->video_packet.stream_index = 1; + + ? ?if (yop->video_packet.data) { + ? ? ? ?*pkt ? ? ? ? ? ? ? ? ? = ?yop->video_packet; + ? ? ? ?yop->video_packet.data = ?NULL; + ? ? ? ?yop->video_packet.size = ?0; + + ? ? ? ?if (!yop->odd_frame) + ? ? ? ? ? ?pkt->flags |= PKT_FLAG_KEY; [...] +static int yop_read_seek(AVFormatContext *s, int stream_index, + ? ? ? ? ? ? ? ? ? ? ? ? int64_t timestamp, int flags) +{ + ? ?YopDecContext *yop = s->priv_data; + ? ?int64_t frame_pos, pos_min, pos_max; + + ? ?av_free_packet(&yop->video_packet); + + ? ?pos_min = s->data_offset; + ? ?pos_max = url_fsize(s->pb) - yop->frame_size; + + ? ?if(!stream_index) + ? ? ? ?return -1; + + ? ?frame_pos ? ? ?= timestamp * yop->frame_size + pos_min; + ? ?yop->odd_frame = timestamp & 1;
this code is a bit inconsistent. are half of the frames really more keyframe than the other half? if not you cannot set keyframe for one half different than the other.
Can I set the flag to some other value? If not, is there some other way the demuxer can tell the decoder if a frame is odd/even?
you could put a 0 or 1 in AVPacket.data[0] but this is ugly, so lets just keep the ugly marking of half of them as keyframes.
if they are you cannot seek to one half
Shouldn't frame_pos = timestamp * frame_size + pos_min; seek(frame_pos); take care of that?
that looks like it can seek to any frame, not just the ones marked as keyframe [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 3 "Rare item" - "Common item with rare defect or maybe just a lie" "Professional" - "'Toy' made in china, not functional except as doorstop" "Experts will know" - "The seller hopes you are not an expert"