Chinaunix首页 | 论坛 | 博客
  • 博客访问: 516196
  • 博文数量: 137
  • 博客积分: 3170
  • 博客等级: 中校
  • 技术积分: 1455
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-17 11:47
文章分类

全部博文(137)

文章存档

2015年(2)

2013年(1)

2012年(6)

2011年(5)

2010年(62)

2009年(61)

我的朋友

分类: Android平台

2015-03-13 11:13:11

采用 gdb研究函数调用关系,要特别注意断点下的位置,do_video_out是一个关键函数,avcodec_encode_video2函数处下断点,可以了解x264编码细节;另外,例如:libavformat/mux.c如下代码:
***1 去理解flv输出细节,
***2 去理解rtmp封包。

点击(此处)折叠或打开

  1. if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
  2.         AVFrame *frame = (AVFrame *)pkt->data;
  3.         av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
  4.         ret = s->oformat->write_uncoded_frame(s, pkt->stream_index, &frame, 0);
  5.         av_frame_free(&frame);
  6.     } else {
  7. ***1        ret = s->oformat->write_packet(s, pkt);
  8.     }

  9.     if (s->flush_packets && s->pb && ret >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS)
  10. ***2        avio_flush(s->pb);


函数调用堆栈:

点击(此处)折叠或打开

  1. (gdb) bt
  2. #0 tcp_write (h=0x663e80, buf=0xca56e0 "g/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro"..., size=128) at libavformat/tcp.c:182
  3. #1 0x00007ffff763ce7d in retry_transfer_wrapper (h=0x663e80, buf=0xca56e0 "g/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro"..., size=128, size_min=128, transfer_func=0x7ffff776b00c <tcp_write>) at libavformat/avio.c:303
  4. #2 0x00007ffff763d079 in ffurl_write (h=0x663e80, buf=0xca56e0 "g/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro"..., size=128) at libavformat/avio.c:352
  5. #3 0x00007ffff7722a7c in ff_rtmp_packet_write (h=0x663e80, pkt=0x6616f8, chunk_size=128, prev_pkt_ptr=0x661698, nb_prev_pkt=0x6616a4) at libavformat/rtmppkt.c:382
  6. #4 0x00007ffff772405b in rtmp_send_packet (rt=0x661680, pkt=0x6616f8, track=0) at libavformat/rtmpproto.c:247
  7. #5 0x00007ffff772cfbb in rtmp_write (s=0x664040, buf=0x6658c0 "\t", size=20444) at libavformat/rtmpproto.c:3048
  8. #6 0x00007ffff763ce7d in retry_transfer_wrapper (h=0x664040, buf=0x6658c0 "\t", size=20444, size_min=20444, transfer_func=0x7ffff772c86f <rtmp_write>) at libavformat/avio.c:303
  9. #7 0x00007ffff763d079 in ffurl_write (h=0x664040, buf=0x6658c0 "\t", size=20444) at libavformat/avio.c:352
  10. #8 0x00007ffff763d74c in writeout (s=0x663f20, data=0x6658c0 "\t", len=20444) at libavformat/aviobuf.c:131
  11. #9 0x00007ffff763d7fb in flush_buffer (s=0x663f20) at libavformat/aviobuf.c:143
  12. #10 0x00007ffff763da7b in avio_flush (s=0x663f20) at libavformat/aviobuf.c:199
  13. #11 0x00007ffff76e6be9 in write_packet (s=0x65fbe0, pkt=0x7fffffffd880) at libavformat/mux.c:603
  14. #12 0x00007ffff76e7c77 in av_interleaved_write_frame (s=0x65fbe0, pkt=0x0) at libavformat/mux.c:907
  15. #13 0x000000000041fae8 in write_frame (s=0x65fbe0, pkt=0x7fffffffdb70, ost=0x660a40) at ffmpeg.c:718
  16. #14 0x00000000004217f1 in do_video_out (s=0x65fbe0, ost=0x660a40, next_picture=0xb8b680) at ffmpeg.c:1127
  17. #15 0x000000000042209d in reap_filters () at ffmpeg.c:1273
  18. #16 0x000000000042ce4c in transcode_step () at ffmpeg.c:3744
  19. #17 0x000000000042cf05 in transcode () at ffmpeg.c:3787
  20. #18 0x000000000042d443 in main (argc=18, argv=0x7fffffffe058) at ffmpeg.c:3964
调用循环,另外的堆栈:

点击(此处)折叠或打开

  1. (gdb) bt
  2. #0 tcp_write (h=0x663e80, buf=0x7fffffffd337 "\306L\323\377\377\377\177", size=1) at libavformat/tcp.c:182
  3. #1 0x00007ffff763ce7d in retry_transfer_wrapper (h=0x663e80, buf=0x7fffffffd337 "\306L\323\377\377\377\177", size=1, size_min=1, transfer_func=0x7ffff776b00c <tcp_write>) at libavformat/avio.c:303
  4. #2 0x00007ffff763d079 in ffurl_write (h=0x663e80, buf=0x7fffffffd337 "\306L\323\377\377\377\177", size=1) at libavformat/avio.c:352
  5. #3 0x00007ffff7722ae4 in ff_rtmp_packet_write (h=0x663e80, pkt=0x6616f8, chunk_size=128, prev_pkt_ptr=0x661698, nb_prev_pkt=0x6616a4) at libavformat/rtmppkt.c:387
  6. #4 0x00007ffff772405b in rtmp_send_packet (rt=0x661680, pkt=0x6616f8, track=0) at libavformat/rtmpproto.c:247
  7. #5 0x00007ffff772cfbb in rtmp_write (s=0x664040, buf=0x6658c0 "\t", size=20444) at libavformat/rtmpproto.c:3048
  8. #6 0x00007ffff763ce7d in retry_transfer_wrapper (h=0x664040, buf=0x6658c0 "\t", size=20444, size_min=20444, transfer_func=0x7ffff772c86f <rtmp_write>) at libavformat/avio.c:303
  9. #7 0x00007ffff763d079 in ffurl_write (h=0x664040, buf=0x6658c0 "\t", size=20444) at libavformat/avio.c:352
  10. #8 0x00007ffff763d74c in writeout (s=0x663f20, data=0x6658c0 "\t", len=20444) at libavformat/aviobuf.c:131
  11. #9 0x00007ffff763d7fb in flush_buffer (s=0x663f20) at libavformat/aviobuf.c:143
  12. #10 0x00007ffff763da7b in avio_flush (s=0x663f20) at libavformat/aviobuf.c:199
  13. #11 0x00007ffff76e6be9 in write_packet (s=0x65fbe0, pkt=0x7fffffffd880) at libavformat/mux.c:603
  14. #12 0x00007ffff76e7c77 in av_interleaved_write_frame (s=0x65fbe0, pkt=0x0) at libavformat/mux.c:907
  15. #13 0x000000000041fae8 in write_frame (s=0x65fbe0, pkt=0x7fffffffdb70, ost=0x660a40) at ffmpeg.c:718
  16. #14 0x00000000004217f1 in do_video_out (s=0x65fbe0, ost=0x660a40, next_picture=0xb8b680) at ffmpeg.c:1127
  17. #15 0x000000000042209d in reap_filters () at ffmpeg.c:1273
  18. #16 0x000000000042ce4c in transcode_step () at ffmpeg.c:3744
  19. #17 0x000000000042cf05 in transcode () at ffmpeg.c:3787
  20. #18 0x000000000042d443 in main (argc=18, argv=0x7fffffffe058) at ffmpeg.c:3964



阅读(6706) | 评论(0) | 转发(0) |
1

上一篇:关于socket阻塞和非阻塞

下一篇:xxxxxxxxx

给主人留下些什么吧!~~